【发布时间】:2019-08-26 09:19:15
【问题描述】:
sendKeys() 没有将完整的字符串插入文本字段。我正在尝试插入电子邮件 ID。
String name = "New Apollo33";
fluent_wait.until(ExpectedConditions.presenceOfElementLocated(By.id("businessname"))).sendKeys(name);
String email = "apollo33@mailinator.com";
fluent_wait.until(ExpectedConditions.presenceOfElementLocated(By.id("businessemail"))).sendKeys(email);
它正在插入名称,但没有完全插入电子邮件 ID。
【问题讨论】:
-
您应该考虑将其分解为至少两个步骤,也许更多。使用流畅的等待,创建 WebElement,清除文本,发送文本。您没有清除任何预先存在的文本。这不是问题,但是将其他三个步骤合二为一并不总是最好的主意。
-
另外,存在只是意味着元素在 DOM 中,而不是可见等。
标签: java selenium selenium-webdriver webdriver webdriverwait