Thursday, May 17, 2012

clicking on different tabs of google page using xpath

Code for clicking on different tabs of Google page using Xpath package google; import com.thoughtworks.selenium.*; import java.util.regex.Pattern; public class Xpath { public static Selenium selenium = null; public static void testUntitled() throws Exception { Selenium selenium = new DefaultSelenium("localhost", 4444, "*chrome","http://www.google.co.in/"); selenium.start(); selenium.open("/"); selenium.click("xpath=.//*[@id='gb_119']/span[2]"); selenium.waitForPageToLoad("30000"); verifyTrue(selenium.isTextPresent("Sign In")); selenium.goBack(); selenium.click("xpath=.//*[@id='gb_1']/span[2]"); selenium.waitForPageToLoad("60000"); assertTrue(selenium.isTextPresent("Google Search")); selenium.goBack(); selenium.click("xpath=.//*[@id='gb_2']/span[2]"); selenium.waitForPageToLoad("60000"); assertTrue(selenium.isTextPresent("")); selenium.goBack(); selenium.click("xpath=.//*[@id='gb_8']/span[2]"); selenium.waitForPageToLoad("60000"); selenium.goBack(); selenium.click("xpath=.//*[@id='gb_78']/span[2]"); selenium.waitForPageToLoad("60000"); selenium.goBack(); selenium.click("xpath=.//*[@id='gb_36']/span[2]"); selenium.waitForPageToLoad("60000"); selenium.goBack(); selenium.click("xpath=.//*[@id='gb_5']/span[2]"); selenium.waitForPageToLoad("60000"); selenium.goBack(); selenium.click("xpath=.//*[@id='gb_23']/span[2]"); selenium.waitForPageToLoad("60000"); selenium.goBack(); selenium.click("xpath=.//*[@id='gb_25']/span[2]"); selenium.waitForPageToLoad("60000"); selenium.goBack(); selenium.click("xpath=.//*[@id='gb_24']/span[2]"); selenium.waitForPageToLoad("60000"); selenium.goBack(); } private static void assertTrue(boolean textPresent) { // TODO Auto-generated method stub } private static void verifyTrue(boolean textPresent) { // TODO Auto-generated method stub } public static void main(String args[]){ try { Xpath.testUntitled(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }

1 comment:

  1. SWIFT Interview questions on

    http://testwithus.blogspot.in/p/swift.htm

    For selenium solution visit
    http://testwithus.blogspot.in/p/blog-page.html


    For QTP interview questions

    http://testwithus.blogspot.in/p/qtp-questions.html


    www.searchyourpolicy.com


    ReplyDelete