package facebook;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class facebook {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver","C:\\Users\\5558\\eclipse-workspace\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.facebook.com");
driver.manage().window().maximize();
driver.findElement(By.xpath(".//*[@id='email']")).sendKeys("abcdefg@gmail.com");
driver.findElement(By.xpath(".//*[@id='pass']")).sendKeys("selenium123");
driver.findElement(By.xpath(".//*[@id='u_0_2']")).click();
driver.quit();
}
}
我收到Exception in thread "main" org.openqa.selenium.NoSuchSessionException: 的错误消息
答案 0 :(得分:0)
像这样Difference between @Before, @BeforeClass, @BeforeEach and @BeforeAll
分隔代码并将驱动程序安装程序设置为@BeforeClass,将driver.quit();
设置为@AfterClass。
即使是虚构的也不要在此处发布凭据。