-1
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();
    }
}

I am getting this error as Exception in thread "main" org.openqa.selenium.NoSuchSessionException:

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56

1 Answers1

0

separate your code like this Difference between @Before, @BeforeClass, @BeforeEach and @BeforeAll

and get driver setup to @BeforeClass and driver.quit(); to @AfterClass.

and don't post credentials here, even if fictional.

pburgr
  • 1,722
  • 1
  • 11
  • 26