Selenium: How To Click On Javascript Button
I must write some scripts for automatic tests to check load-time a web application built in flex/amf technology. The test will consist in opening the IE browser, going through seve
Solution 1:
Don't go through JavaScript. Try this:
String xPath = "//button[contains(.,'Login')]";
driver.findElement(By.xpath(xPath))).click();
Better yet, but not tested:
// xPath to find a button whose text() (ie title) contains the word LoginStringxPath="//button[contains(text(),'Login')]";
driver.findElement(By.xpath(xPath))).click();
Please also note that https://sqa.stackexchange.com/ has info on Selenium (etc.)
Solution 2:
As per the HTML you have shared to invoke click()
on the desired element you can use the following solution:
driver.findElement(By.xpath("//button[normalize-space()='Login']")).click();
On another perspective the desired element looks JavaScript enabled and that case you have to induce WebDriverWait for the element to be clickable and you can use the following solution:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[normalize-space()='Login']"))).click();
Post a Comment for "Selenium: How To Click On Javascript Button"