Transformation from Manual tester to a Selenium WebDriver Automation specialist !!!
RSSS

A Small guide for a tester transformation into a WebDriver scripter


 This table will be very useful for a selenium beginner who is trying out selenium WebDriver

WebDriver Commands Category

 

Tasks Human Interaction (Manual Tester) WebDriver Commands
Invoke Browser Tester manually opens the browser Firefox, IE, chrome or Safari [sourcecode language="java"]WebDriver driver=new FirefoxDriver();
WebDriver driver=new SafariDriver();
WebDriver driver=new chromeDriver();
WebDriver driver=new InternetExplorerDriver();[/sourcecode]

This is actually a WebDriver object instantiation and
this will invoke the browser according to different
WebDriver implementation.

Load URL of Application Tester manually type’s in the URL

http://www.google.com

[sourcecode language="java"]driver.get("http://www.google.com");[/sourcecode]

Loads the given url into the browser

Click Tester clicks on the Search field in the Google home page [sourcecode language="java"]driver.findElement(By.cssSelector("#gbqfq")).click();
driver.findElement(By.cssSelector("#gbqfq")).clear();[/sourcecode]

Click actually comes with clear command in WebDriver.
Clear command will simply clear the input field. Basically
to avoid the auto-form fill.

Type Tester types the words manually [sourcecode language="java"]driver.findElement(By.cssSelector("#gbqfq")).sendKeys("test");
[/sourcecode]

Types “test” into the input element identified by css selector.

Select from Drop-down Tester clicks on the Drop-down field and selects the required option [sourcecode language="java"]Select select = new Select(driver.findElement(By.tagName
("select")));
select.selectByVisibleText("Apple");[/sourcecode]

Selects the text
displayed as “Apple” in the select combo box which
is identified by tag name “select”

Moving between Windows Tester will simply click on the window or will do a Alt+tab combination to toggle between windows [sourcecode language="java"]driver.switchTo().window("windowName");
driver.switchTo().frame("frameName");[/sourcecode]

We can switch between frames or iframes using above command.

Alert Handling Tester knows that Alert will be pop-up and then asserts it. [sourcecode language="java"]driver.findElement(By.xpath (“<Xpath>”)).click();
Alert alert = driver.switchTo().alert();
alert.accept();[/sourcecode]

Note : Alert provides methods like accept(), dismiss(),  getText().

Browser forward/back button Tester will be clicking on the browser back and forward button [sourcecode language="java"]driver.navigate().forward();driver.navigate().back();
[/sourcecode]

Navigate back and forth in the browser

Drag and Drop Tester uses the mouse movement and drags the element to destination and drops it. [sourcecode language="java"]WebElement source = driver.findElement(By.name("source"));
WebElement target = driver.findElement(By.name("target"));
(new Actions(driver)).dragAndDrop(source, target).perform();[/sourcecode]

Performs the drag from source to target.

Mouse Hover Tester just places the mouse over the element [sourcecode language="java"]Actions builder = new Actions(driver);
WebElementtagElement =
driver.findElement(By.id("someid"));
builder.moveToElement(tagElement).build().perform();[/sourcecode]

Simulates the mouse hover on the element identified by id.

Check/UnCheck Tester performs this manually using mouse on the specific check boxes [sourcecode language="java"]WebElement checking =
driver.findElement(By.name("your locator by name"));checking.click();
System.out.println(checking.isSelected());
[/sourcecode]

Performs Check/Uncheck of the check box identified by name

Select Radio button Tester performs this manually using mouse on the specific Radio button [sourcecode language="java"]WebElement radiogender = driver.findElement(By.xpath("//input[@name='male']"));         radiogender.click();
System.out.println(gender.isSelected());
[/sourcecode]

Selects the radio button identified by name as ‘male’

AssertElementPresent Tester checks whether the element is displayed [sourcecode language="java"]assertTrue(isElementPresent(By.xpath("Some xpath")));[/sourcecode]

Checks whether element identified by XPath is present in the webpage or not.

Extract some Text from Application Tester just use the copy paste command [sourcecode language="java"]String gettingtext =
driver.findElement(By.xpath("some xpath")).getText();[/sourcecode]

Gets the text of the element identified by xpath.

Submit a form Tester just clicks on the submit button on page [sourcecode language="java"]driver.findElement(By.id(“your locator by id”)).submit();[/sourcecode]

Submits the form identified by id.

Hope this will help a selenium beginner, please leave your comments if any and do share

29 thoughts on “Transformation from Manual tester to a Selenium WebDriver Automation specialist !!!

  1. November 5, 2012 at 12:50 am

    Magnificent goods from you, man. I have understand your stuff previous to and you’re just too great. I actually like what you have acquired here, really like what you’re stating and the way in which you say it. You make it entertaining and you still care for to keep it smart. I can’t wait to read much more from you. This is actually a wonderful web site.

    1. November 5, 2012 at 2:36 pm

      Thanks for your kind words Vanesa Delgado.

  2. Ashly Suet
    November 15, 2012 at 10:05 pm

    Awesome info and well written. Keep up the good stuff!

    1. November 16, 2012 at 9:07 am

      Thanks a lot.

  3. November 20, 2012 at 6:35 pm

    Hi,
    its really a very good article for starters like me.
    Thank you very much, keep gooing

    1. November 20, 2012 at 6:38 pm

      I am glad it helps you. Keep visiting the blog for more posts.

  4. Suresh
    December 2, 2012 at 9:53 pm

    every one can understand this…very well explained…

    1. December 2, 2012 at 10:05 pm

      Thanks Suresh. Its made for beginners..!!!

  5. Richa
    December 12, 2012 at 11:25 am

    Good check list, very useful for beginners.
    Thank u

    1. December 12, 2012 at 11:40 am

      Thanks for your kind words. http://facebook.com/AssertSelenium pls give a Like and publicize amongst your friends.

  6. Hariharan M
    December 20, 2012 at 11:07 am

    Awesome Post, really helpful for beginners in selenium..

    1. December 20, 2012 at 11:18 am

      Thanks Hariharan

  7. Geeta Chaudhari
    December 27, 2012 at 3:14 pm

    Hi,
    This is really helpful.

    Just a small request – Can you please explain when/why/which cases do we use JavaScriptExecutor in WebDriver?

    -Geeta

    1. December 27, 2012 at 3:46 pm

      Hi Geeta,
      Good Question.

      There are some times, when the tool doesn’t perform what we wanted to do exactly.
      Example: sometimes the tool has not interacted with a page correctly, [or] has failed to react when an XmlHttpRequest returns [or] it hasn’t emitted the correct events.

      So, at this situation using the JavaScriptExecutor will be a handy workaround.

      Hope that helps.

      1. Suresh
        December 27, 2012 at 3:49 pm

        hi manoj,
        can u pls share with us an example scenario , so that we can understand better..
        thank you.

        1. December 27, 2012 at 4:03 pm

          Well, this is based on any particular scenario where the Selenium or WebDriver could not interact on any element in a webpage
          In Selenium RC : we used getEval() API
          In WebDriver we are using JavaScriptExecutor

          I will have to search for that functionality where it cannot interact. let me see whether I can make it as blog post itself.
          Thanks

  8. Mayur. J
    January 7, 2013 at 4:43 pm

    Really useful, thanks a lot… was searching for a list like this from a loong time, finally i found this from you.. keep going..and add more n more tuts for QA begenners. -God bless !!

    1. January 8, 2013 at 12:30 pm

      Thanks Mayur, I am glad its helpful for you.

  9. swa
    January 18, 2013 at 12:03 pm

    very useful commands,really appreciate for your knowledge sharing

    1. January 18, 2013 at 12:05 pm

      swa,

      thanks, hope you have subscribed and Like’d the page at FB

  10. ranjithkumar
    February 26, 2013 at 11:38 am

    awesome work .. really interesting and helps a lot beginners like me..thanks a lot..and plz keep post some advanced topics too..

  11. February 26, 2013 at 7:14 pm

    It has really helped me a lot….. very well explained.. :)

  12. Sush
    March 21, 2013 at 5:33 pm

    Brilliant ! Indeed very helpful! Keep posting more links :) as we are moving to next phase from Beginners!

    1. March 21, 2013 at 5:37 pm

      Oh.. That’s great. Like your confidence on moving to next phase :) Keep visiting.

  13. Prasanth
    March 25, 2013 at 2:44 pm

    Hi manoj, very great work frm u, i just came across some useful selenium blogs,inorder to suggest to new selenium learners, and ur contents are really superb and its easy to understnd for new selenium learner……Keep updating manoj

  14. venkatesh
    May 15, 2013 at 1:43 pm

    Nice blog regarding selenium, i am planning to learn selenium can u please share related documents to following mail id : tativenky@gmail.com.

    1. May 16, 2013 at 10:50 am

      There is nothing to be emailed as a study material, all you can do is Go through the Selenium documentation and try it on your own and if you struggle anywhere look for blog posts like this. You will be good at Selenium scripting.

  15. Venkatesh
    May 17, 2013 at 9:38 am

    Daily 2hrs enough for learning selenium ? if yes, total how many months ll take to reach medium level.

  16. Amit goyal
    May 19, 2013 at 9:26 am

    this is extremely good. This is very helpful for beginner. should also explain some more controls like list control, date picker control and the different ways of identifying the elements.

Leave a Reply

Your email address will not be published. Required fields are marked *