This is my code
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\xyz");
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\zyx");
WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.get("localserver:9091/");
Duration timeoutDuration = Duration.ofSeconds(5);
WebDriverWait wait = new WebDriverWait(driver, timeoutDuration);
WebElement usernameInput = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("userNameLi")));
WebElement passwordInput = driver.findElement(By.id("userPasswordLi"));
usernameInput.sendKeys("001");
passwordInput.sendKeys("t01");
WebElement loginButton = driver.findElement(By.xpath("/html/body/table/tbody/tr/td[2]/center/div/form/button"));
loginButton.click();
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
wait.until(ExpectedConditions.alertIsPresent());
alert.accept();
}
As soon as the alert.accept() gets executed the following error arises
WARNING: Unable to find an exact match for CDP version 123, returning the closest version; found: 122; Please update to a Selenium version that supports CDP version 123
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Not attached to an active page"}
(Session info: chrome=123.0.6312.58)
Build info: version: '4.18.1', revision: 'b1d3319b48'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.6'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [dfac2cd703b05551ae6f7883aac610a4, acceptAlert {}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 123.0.6312.58, chrome: {chromedriverVersion: 123.0.6312.58 (6b4b19e9dfbb..., userDataDir: C:\Users\asaph\AppData\Loca...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:50271}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: windows, proxy: Proxy(), se:cdp: ws://localhost:50271/devtoo..., se:cdpVersion: 123.0.6312.58, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
Session ID: dfac2cd703b05551ae6f7883aac610a4
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.openqa.selenium.remote.ErrorCodec.decode(ErrorCodec.java:167)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:138)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:50)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:190)
at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:519)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:592)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:596)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteAlert.accept(RemoteWebDriver.java:1180)
at swagger.swapnil.Selenium.main(Selenium.java:44)
PS:I have tried switching frames adding timeouts but still getting this error
I didn't find the downgraded version of (cft) chrome browser or chromedriver on seleium website and that warning should be safe to ignore as stated in many videos i watched.
PS : This is a website that runs on local server and i am using lan to access it.
the page is supposed to navigate to other page after the alert is accepted.