2017-07-25 75 views
0

有一个很难将文本输入凭据页: Pixiv选择输入场 - 元素不可见

<div class="input-field-group"> 
<div class="input-field"> 
<input placeholder="E-mail address/pixiv ID" autocapitalize="off" value="" type="text"> 
</div> 
<div class="input-field"> 
<input placeholder="Password" autocapitalize="off" value="" type="password">             
</div> 
</div> 

我使用下面的代码作为id属性是不可选择的领域:

driver.findElement(By.xpath("//input[@placeholder='Password']")); 

但我无法通过sendKeys操纵元素也不清楚。 它分别抛出了以下情况除外:

org.openqa.selenium.ElementNotInteractableException: Element is not visible 
org.openqa.selenium.InvalidElementStateException: Element is not currently interactable and may not be manipulated 

回答

1

居然有此页面上有两个元素使用XPath的。 webdriver将选择符合开发人员设置要求的第一个元素。不幸的是,你想要的元素是DOM中的第二个元素。但是更新XPath以获得更具体的信息将有所帮助:

driver.findElement(By.xpath("//div[@id='container-login']//input[@placeholder='Password']"));