[英]Selenium: Unable to locate element on PayPal Login Page
我目前正在使用页面对象代表PayPal登录页面( https://www.sandbox.paypal.com ),以实现自动化目的,无论我做什么,我似乎都无法单击页面上的“登录”按钮。
页面外观如下: 这是贝宝登录页面的当前页面对象表示形式:
public class PayPalLoginPage extends DesktopPage {
private static final Logger LOG = LoggerFactory.getLogger(PayPalLoginPage.class);
@FindBy(id = "email")
private WebElement emailInput;
@FindBy(id = "password")
private WebElement passwordInput;
@FindBy(id = "btnLogin")
private WebElement loginButton;
public PayPalLoginPage(BuildWebDriver driver, Wait<WebDriver> wait) {
super(driver, wait);
}
public void setEmail(String email) {
LOG.debug("Setting email: " + email);
setTextWithJavascript(emailInput, email);
}
public void setPassword(String password) {
LOG.debug("Setting password: " + password);
setTextWithJavascript(passwordInput, password);
}
public PayPalPaymentsPage clickLoginButton() {
LOG.debug("Clicking 'Log In' Button.");
clickWithJavascript(loginButton);
return new PayPalPaymentsPage(driver, wait);
}
}
不管我做什么,我似乎都无法与电子邮件/密码输入框和“登录”按钮交互。 获取错误,例如: no such element: Unable to locate element: {"method":"id","selector":"btnLogin"}
我尝试使用更好的方法通过webElement.sendKeys(String keys)
设置带有电子邮件/密码的输入字段,但这会导致诸如以下错误: Stack Trace org.openqa.selenium.ElementNotVisibleException: element not visible
。 试图等待元素的可见性超时。 Javascript似乎是与页面交互的唯一方法(也是我的最后一招),但是JavaScript甚至失败了。
有人知道我在做什么错吗? 谢谢。
您尝试与之交互的元素位于iframe内部,因此位于另一个文档中。 您将需要找到一种使用Selenium在iframe中进行选择的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.