Wednesday, 4 November 2015

টুকি টাকি Java

আই ব্লগ এর মুল উদ্দেশ্য জাভা related টুকিটাকি বিষয় বস্তু তালিকাবদ্ধ করা। কিছু কিছু জিনিস যা কাজে লাগতে পারে।
1. Importing a package into another package
   Import package_name.*
2. Importing a class of a particular package
   Import package_name.class_name

Sample code:

Wednesday, 7 October 2015

Integrating Autoit and Selenium: Uploading a file using autoit

While automating a web application I faced a challenge. The challenge is integrate autoit and selenium. So I am going to share the problem domain and the coded solution below so that others can find it out helpful

Problem domain: I have a file located in my own machine which I need to upload in one of my web application project

Used tool:
1. Selenium for automating web application
2. Autoit for interacting with windows/ uploading a file from own local machine

Step 1: Autoit code
Write the Autoit code:

ControlFocus("File Upload","","Edit1")
ControlSetText("File Upload","","Edit1","D:\Test\Shp\Vegetation.zip")
ControlClick("File Upload", "", "Button1")

First write this autoit code and then save it using the extension, Example: fileupload.au3

Step 2: Compile script(Convert into .exe format)

Right click on the fileupload.au3 file and hit compile script, If you are using a 32 bit OS then choose x86 option and if you are using a 64 bit os then choose x64 option

Step 3: Integrating with selenium

Write only the following line in your selenium code where you need to upload you file

Runtime.getRuntime().exec("C:\\Users\\example\\Desktop\\fileupload.exe")

(It is the file path of the .exe file)

Then run your selenium code and observe the expected result

This code works fine for me hope you will find this helpfull



Thursday, 1 October 2015

Draw in canvas using selenium web driver and java

Drawing 3 points which will create a polygon


WebElement element = driver.findElement(By.xpath("html/body/div[3]/div[2]/div[2]/div[2]/div/canvas"));

Actions builder = new Actions(driver);
    Action drawAction = builder.moveToElement(element,135,15)  // start point in the canvas
    //signatureWebElement is the element that holds the signature element you have in the DOM
              .click()
              .moveByOffset(200, 60) // second point
              .click()
              .moveByOffset(100, 70) // third point
              .doubleClick()
              .build();
    drawAction.perform();

Wednesday, 10 June 2015

Code academy: Function: 3/19: Calling a function with parameter

We've set up a function, square. Call it on the number 10 (by putting 10between the parentheses of square()) on line 9!

Solution:
def square(n):
    """Returns the square of a number."""
    squared = n**2
    print "%d squared is %d." % (n, squared)
    return squared
    
# Call the square function on line 9! Make sure to
# include the number 10 between the parentheses.

square(10)

Sunday, 31 May 2015

== Search Text for Your Name ==
We'll want to place the if statement inside our for loop to make sure the program checks the if statement each time it moves forward through the loop. Essentially, the for loop is saying: "Hey program! Go through every letter in 'text'." The if statement will say: if you see something interesting, push that text into an array!"

var myArray =  ['a', 'b', 'c'];
myArray[0]; // equals a.

Instructions:
Add your if statement in the body of your for loop. It should check to see whether the current letter is equal to the first letter of your name. (Capitalization counts!)
There's no need to put anything between the {}s of your if just yet.

Solutions:

var text = "Hello world Keya how you doing Keya";
           
var myName ="Keya";
var hits = [];
for(var i=0; i<text.length; i++ )
{
    if (text[i]=== 'K')
    {
        }
    }
While loop: Tutorial 5/11
== Practice makes perfect ==
Problem: Write a while loop that logs "I'm looping!" to the console three times. You can do this however you like, but NOT with three console.log calls. Check the Hint if you need help!

Solve:
var count= 0;

var loop = function(){
    while(count < 3){
        console.log("I'm looping!");
        count++;
    }
};

loop();

Python Pig Latin 4/11


print "Welcome to the Pig Latin Translator!"

# Start coding here!
original = raw_input("Enter a word:")
if len(original) > 0:
    print original
else:
    print "empty"