I am currently automating a website using Selenium. The issue I am facing is that every time the code runs, I have to login again and GeckoDriver opens a new tab in Firefox to fill in the login details. Is there a more efficient way to handle this?
Below is a snippet of my code:
WebDriver driver = new FirefoxDriver();
driver.get("https://www.instagram.com/");
Thread.sleep(5000);
WebElement username = driver.findElement(By.cssSelector("form#loginForm > div > div > div > label > input"));
WebElement password = driver.findElement(By.cssSelector("form#loginForm > div > div:nth-of-type(2) > div > label > input"));
Thread.sleep(3000);
username.sendKeys("username");
password.sendKeys("password");
password.sendKeys(Keys.ENTER);