【发布时间】:2019-02-24 09:08:00
【问题描述】:
我编写了一个简单的代码来在 facebook 登录页面中输入电子邮件。但是在通过 sendKeys 输入电子邮件值时,我得到了类似“方法 sendKeys(String) 未定义类型 By”的验证。我已经检查了 1.8 的合规性版本。那么这里出了什么问题???下面是代码sn-p:
package SeleniumTests;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class OpenFacebook {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver","geckodriver path");
WebDriver driver=new FirefoxDriver();
driver.get("http:\\facebook.com");
driver.manage().window().maximize();
driver.findElement(By.xpath("//[@id='email']").sendKeys("swarup.wipro@gmail.com");
}
}
作为快速修复,我获得了 Add cast to By.xpath 选项。有人可以解释一下这个的用法还是有其他可用的解决方案
【问题讨论】:
标签: java selenium xpath css-selectors webdriver