Issue I am facing:
After this step: driver.findElement(By.linkText("New Customer")).click();
an advertisement window opens and script stops here. I'm unable to close the advertisement and continue further navigation/testing.
I'm still learning and hence not sure what I should do. I need help with this situation.
I ordered to stop the advertisement window during whole program (don't want Advertisement at all).
Advertisement is different every time I run the script.
package selenium;
import java.sql.Array;
import java.util.Arrays;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class gure99 {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Users\\Admin\\Downloads\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://demo.guru99.com/");
driver.manage().window().maximize();
driver.get("https://demo.guru99.com/");
driver.manage().window().maximize();
driver.findElement(By.name("emailid")).sendKeys("<my username>");
driver.findElement(By.name("btnLogin")).click();
driver.get("https://demo.guru99.com/V4/");
driver.findElement(By.name("uid")).sendKeys("mngr385415");
driver.findElement(By.name("password")).sendKeys("<my password>");
driver.findElement(By.name("btnLogin")).click();
driver.manage().window().maximize();
driver.findElement(By.linkText("New Customer")).click();
Thread.sleep(5000);
driver.switchTo().alert().sendKeys("Close");
Thread.sleep(5000);