Selenium Java to locate web element by XPath using text() method
KW.java
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; class KW { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "/home/kodingwindow/drivers/chromedriver"); WebDriver driver = new ChromeDriver(); driver.navigate().to("https://kodingwindow.com/testapp/"); driver.findElement(By.xpath("//*[contains(@name,'ername')]")).sendKeys("kodingwindow"); driver.findElement(By.xpath("//*[contains(@name,'passw')]")).sendKeys("kodingwindow"); driver.findElement(By.xpath("//*[text()='Reset']")).click(); driver.close(); } }
Comments and Reactions
What Next?
Selenium Java to locate a web element using the last() method
Selenium Java to locate a web element using the following and preceding XPath axes
Selenium Java to select the radio button using XPath
Advertisement