Simple Button Click Event Example.
WebElement test=driver.findElement(By.name("Test"));
String str = btnLogin.getText();
Assert.assertTrue(str.contains("Test"));
test.click();
Simple Button Click Event Example.
WebElement test=driver.findElement(By.name("Test"));
String str = btnLogin.getText();
Assert.assertTrue(str.contains("Test"));
test.click();
Seems like you are referring to some other variable while assigning a value to str
which is not shared by you in the post :
WebElement test=driver.findElement(By.name("Test"));
String str = btnLogin.getText();
btnLogin
and test
are different elements. OR you might wanted to use :
WebElement test=driver.findElement(By.name("Test"));
String str = test.getText();