Xpath assignment | Selenium Forum
D
Dheeraj Vazirani Posted on 18/08/2020

Xpath Assignment

 

@Test
public void nukllskull() {

WebDriver driver = launchBrowser("Chrome");
driver.get("http://nullskull.com/articles/sumCaptchaTest.aspx");


driver.findElement(By.name("email")).sendKeys("www.qtpselenium.com");

String A,B;

A = driver.findElement(By.xpath("//*[@id='Form1']/div[3]/span[2]")).getText();
int a = Integer.parseInt(A); // convert String to Integer


B = driver.findElement(By.xpath("//*[@id='Form1']/div[3]/span[4]")).getText();
int b = Integer.parseInt(B); // convert String to Integer

int sum = a+b; // get sum of a + b
String sum2 = Integer.toString(sum); // convert sum to String and store as sum2

driver.findElement(By.name("txtSum")).sendKeys(sum2); // pass sum2 (String) in the input text box

driver.findElement(By.xpath("//*[@id='Button1']")).click(); find link and click

}


A
Ashish Replied on 19/08/2020

Yes thats correct !


Related Posts