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

Xpath Assignment


public void nukllskull() {

WebDriver driver = launchBrowser("Chrome");


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


Ashish Replied on 19/08/2020

Yes thats correct !

Related Posts