我正在尝试登录 this 。在其中单击“登录”,我已成功完成此操作。现在,当尝试使用 Xpath 输入用户名/密码时,它会显示异常,其中显示
Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not visible
代码是:-
driver.findElement(By.xpath(".//*[@id='load_form']/fieldset[1]/input")).sendKeys("test123");
driver.findElement(By.xpath(".//*[@id='load_form']/fieldset[2]/input")).sendKeys("test123");
我知道这个Xpath
与SignUp
表单中使用的相同,那么定位这两个字段的其他方法是什么?我们如何通过cssselector
来使用它?
感谢您提前提供的帮助。
最佳答案
通过查找相对 xpath 上升一级
//div[@id='login']/form[@id='load_form']//input[@name='username']
//div[@id='login']/form[@id='load_form']//input[@name='password']
关于 Selenium 网络驱动程序 : cssselector,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38326303/