Hey everyone,
Currently, I'm working on a Java Selenium script that automates clicking and filling forms for me. I've written a line of code that's causing me some trouble. The intention is to click on a button, but it's not happening as expected. When I run the script, the bot scrolls down to the button but doesn't actually click on it. Clicking on the button should ideally open a new page. I'm unsure of what went wrong; can someone assist me with this? Appreciate any help!
Snippet of My Code:
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().window().fullscreen();
driver.get("https://deutsche-giganetz.de/");
driver.findElement(By.xpath("/html/body/section/div/div[1]/div[2]/button[1]")).click();
driver.findElement(By.xpath("/html/body/header/div/div/nav/div/div[1]/div[2]/ul/li[1]/a")).click();
driver.findElement(By.xpath("/html/body/main/div[8]/div/section/div/div[1]/div[2]/div[3]/div[1]/div/div[5]/a")).click();
}
}
Error Details:
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 108.0,
moz:accessibilityChecks: false, moz:buildID: 20221208122842, moz:debuggerAddress: 127.0.0.1:38233,
moz:geckodriverVersion: 0.32.0, moz:headless: false, moz:platformVersion: 10.0, moz:processID: 15732, moz:profile: C:\Users\OKANAY~1\AppData\L..., moz:shutdownTimeout: 60000,
moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, moz:windowless: false, pageLoadStrategy: normal, platformName: WINDOWS, proxy: Proxy(), se:cdp:
ws://127.0.0.1:38233/devtoo..., se:cdpVersion: 85.0, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Element: [[FirefoxDriver: firefox on WINDOWS (dae2e314-a112-48de-ada9-bd6ffce54a94)]
-> xpath: `/html/body/main/div[8]/div/section/div/div[1]/div[2]/div[3]/div[1]/div/div[5]/a]
Session ID: dae2e314-a112-48de-ada9-bd6ffce54a94
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
I attempted using "findelement css selector" instead of "findelement xpath". However, implementing it via a link wasn't feasible due to multiple buttons named "Order Now". Despite extensive research efforts, I couldn't find an alternative solution.