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

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
WebDriver driver=new FirefoxDriver();
WebDriver driver=new SafariDriver();
WebDriver driver=new chromeDriver();
WebDriver driver=new InternetExplorerDriver();

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
driver.get("http://www.google.com");

Loads the given url into the browser

Click Tester clicks on the Search field in the Google home page
driver.findElement(By.cssSelector("#gbqfq")).click();
driver.findElement(By.cssSelector("#gbqfq")).clear();

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
driver.findElement(By.cssSelector("#gbqfq")).sendKeys("test");

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
Select select = new Select(driver.findElement(By.tagName
("select")));
select.selectByVisibleText("Apple");

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
driver.switchTo().window("windowName");
driver.switchTo().frame("frameName");

We can switch between frames or iframes using above command.

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

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

Browser forward/back button Tester will be clicking on the browser back and forward button
driver.navigate().forward();driver.navigate().back();

Navigate back and forth in the browser

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

Performs the drag from source to target.

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

Simulates the mouse hover on the element identified by id.

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

Performs Check/Uncheck of the check box identified by name

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

Selects the radio button identified by name as ‘male’

AssertElementPresent Tester checks whether the element is displayed
assertTrue(isElementPresent(By.xpath("Some xpath")));

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
String gettingtext =
driver.findElement(By.xpath("some xpath")).getText();

Gets the text of the element identified by xpath.

Submit a form Tester just clicks on the submit button on page
driver.findElement(By.id(“your locator by id”)).submit();

Submits the form identified by id.

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

Comments
33 Responses to “Transformation from Manual tester to a Selenium WebDriver Automation specialist !!!”
  1. 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.

  2. Ashly Suet says:

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

  3. azizmudgal says:

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

  4. Suresh says:

    every one can understand this…very well explained…

  5. Richa says:

    Good check list, very useful for beginners.
    Thank u

  6. Hariharan M says:

    Awesome Post, really helpful for beginners in selenium..

  7. Geeta Chaudhari says:

    Hi,
    This is really helpful.

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

    -Geeta

    • 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.

      • Suresh says:

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

      • 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 says:

    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 !!

  9. swa says:

    very useful commands,really appreciate for your knowledge sharing

  10. ranjithkumar says:

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

  11. Sunakshi says:

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

  12. Sush says:

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

  13. Prasanth says:

    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 says:

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

    • Manoj Kumar says:

      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 says:

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

  16. Amit goyal says:

    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.

  17. Rama says:

    Really very helpful, Looking for advanced topics …. thank you for the information,

  18. Hari says:

    Wonderful and an very interesting link for a newbie. Looking forward for an advanced level.

    Keep rocking !!!

  19. Madiraju Krishan Chaitanya says:

    Hi Manoj Kumar,
    First of ALL… I would like to Thank You for the wonderful article.Thanks a LOT.For beginners like us,this website is very handy and easy to understand.Please do keep posting articles on Selenium(IDE and WebDriver) and Core Java too.You can add me to your Fans List… ;-).

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: