我正在尝试用webdriver查找username元素。该网页是用聚合物开发的,html内容是:
<gui-input class="flex style-scope login-window x-scope gui-input-0" id="username" icon="account-circle" label="Username" autofocus="" floating-label="">在Selenium中,我尝试了这样的方法:
driver.findElement(By.className("gui-input#username")).isDisplayed()但是它找不到用户名字段。
有什么帮助吗。谢谢
发布于 2016-04-04 20:43:26
根据类名,定位器需要一个类名,但您正在传递一个CSS选择器。
相反,使用"by CSS选择器“定位器:
driver.findElement(By.cssSelector("gui-input#username"))或“由身份证”:
driver.findElement(By.id("username"))https://stackoverflow.com/questions/36412484
复制相似问题