top of page

Selenium Builder – Exporting and execution

  • Writer: khyati sehgal
    khyati sehgal
  • May 26, 2014
  • 2 min read

In continuation of 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. Let’s start with an example : I have opened a website in firefox and I want to automate some actions on this page. Let’s 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 my column.

And that’s all.

What I will do for this is,

  1. open the firefox

  2. launch the Selenium Builder.

  3. start doing the above steps.

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


SeleniumBuilderCapture

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

What all you can do here?

You can customize your locators over name, id, class, CSS, paths (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 it’s 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 🙂

Comments


bottom of page