Selenium Builder – Exporting and execution

In continuation with my last blog I will here share a more advanced capability of Selenium Builder.
Now as we are done with the set up we can talk one step ahead. Lets start with an example :
I have opened a website in firefox and I want to automate some actions on this page . Lets say :

  1.  I want to open the url (https://khyatisehgal.wordpress.com/).
  2. I need to check a blog on this website , the very first one .
  3. I want to see the author’s about me column.

And that’s all.

What I will do for this is ,

  1. I will open the firefox
  2. I will launch Selenium Builder.
  3. I will start doing the above steps .

And now Selenium builder will record all the steps like this:

SeleniumBuilderCapture

 

Now , stop recording , by clicking on stop recording button.

What all you can do here ?

You can customize your locators over name , id , class, css , xpaths (for more info over selenium see this) . All you need to do is click on the locator you want to edit/update and just click Ok . Builder will show all options available and you can pick one.

CustomizeLocators

 

Exporting Commands from Selenium Builder to Eclipse IDE:

Exporting is a great feature of Selenium Builder where-in you can export your whole test case into the desired Programming Language.

Steps to perform export :

1. Click on the export button on the top of the menu bar under File.

ExportSteps

2. You will get a screen where-in you can select the type of export you want to continue with:

ChooseExportFormat

3. Then you can actually select the option, once this is done . You will get a pop up where you need to tell Selenium builder an option to which location you want to keep this exported file.

4. Once this is done ,open this file and create a project in eclipse IDE or you can place this test case in your existing selenium  project.

Lastly you need to copy the code in Eclipse IDE .Here is the glimpse of code which you will get :

public class {
FirefoxDriver wd;

@Before
public void setUp() throws Exception {
wd = new FirefoxDriver();
wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}

@Test
public void () {
wd.get(“http://khyatisehgal.wordpress.com/”);
wd.get(“http://khyatisehgal.wordpress.com/”);
wd.findElement(By.cssSelector(“h1.entry-title > a”)).click();
wd.findElement(By.linkText(“ABOUT THE AUTHOR”)).click();
wd.findElement(By.cssSelector(“div.site-branding”)).click();
wd.findElement(By.linkText(“Twitter”)).click();
}

@After
public void tearDown() {
wd.quit();
}

public static boolean isAlertPresent(FirefoxDriver wd) {
try {
wd.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}

And its done. No coding , no locator finding , and you are there , ting-ting-tining !!!

Please share your experience /feedback if you have any with Selenium builder. I will be happy to connect to you :)

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s