Unable to click buttons with HtmlUnitDriver but able to click buttons with FirefoxDriver

33 Views Asked by At

I have a code using Selinium HtmlUnitDrive. I'm able to access the website and click the except cookies but I can't seem to click the play demo button. I don't what is a problem because I can click all buttons using FirefoxDriver.

Before I could not access any elements using HtmlUnitDriver until I used WebDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX, true);

Can someone assist because I'm looking to use HtmlUnitDriver.

1

There are 1 best solutions below

0
undetected Selenium On

Possibly it's a typo as there are no blank spaces between Pl and ay. Effectively, you code block would be:

//CLICK DEMO BUTTON
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[text()='Play Demo ']"))).click();
System.out.println("DEMO BUTTON CLICKED");

Accomodating the blank space, you can use:

wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[normalize-space()='Play Demo']"))).click();