在为登录提供Xpath之后,当我通过selenium测试脚本时,无法单击“登录”按钮。 场景 - •通过提供用户名和密码登录应用程序。
public class Myclass {
public static void main(String[] args) throws IOException, InterruptedException {
System.setProperty("webdriver.gecko.driver","C:\\Users\\karokiaswamy\\Documents\\Selenium_installation\\geckodriver-v0.15.0-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
Runtime.getRuntime().exec("c:\\autoit\\HandleAuth.exe");
driver.get("Application URL");
//Runtime.getRuntime().exec("C:\\autoit\\HandleAuth.exe");
Thread.sleep(1000);
driver.get("Application URL");
driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[1]/input")).clear();
driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[1]/input")).sendKeys("testtrack");
driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[2]/input")).clear();
driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[2]/input")).sendKeys("password01");
driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[3]/button")).clear();
driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[2]/input")).sendKeys(" ");
driver.findElement(By.xpath("///button[@class ='btnSmall btnGreen']")).click();
//driver.findElement(By.xpath(".//*[@id='siteLoginTab']/form/table/tbody/tr[1]/td[3]/button")).click()
}
}
答案 0 :(得分:0)
如果我了解你,点击登录按钮后会出现异常。 如果你这样做,你可以点击javascript为:
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click()", element);