I am facing an issue where I am unable to click on an element with the onclick tag using HtmlUnitDriver.
I have tried different methods to resolve this problem.
Using the click method;
public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME, true); driver.get(appURL); WebElement dripBoxbutton = driver.findElement(By.xpath("//img[@class='idp-image']/..")); dripBoxbutton.click();
Using the submit method;
public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME, true); driver.get(appURL); WebElement dripBoxbutton = driver.findElement(By.xpath("//img[@class='idp-image']/..")); dripBoxbutton.submit();
However, I encountered an error when using the submit button:
Error message: javax.script.ScriptException: Sourced file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : dripBoxbutton .submit ( )import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Method Invocation dripBoxbutton.submit : at Line: 48 : in file: inline evaluation of:
Target exception: java.lang.StackOverflowError in inline evaluation of: ``import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' at line number 48
Response headers:
Trying key release
import org.openqa.selenium.Keys; public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME, true); driver.get(appURL); WebElement dripBoxbutton = driver.findElement(By.xpath("//img[@class='idp-image']/..")); dripBoxbutton.sendKeys(Keys.ENTER);
Encountered errors while using key release:
Error message: javax.script.ScriptException: Sourced file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Error in method invocation: Method sendKeys( org.openqa.selenium.Keys ) not found in class'org.openqa.selenium.htmlunit.HtmlUnitWebElement' : at Line: 49 : in file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : dripBoxbutton .sendKeys ( Keys .ENTER )
in inline evaluation of: ``import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' at line number 49
Response headers:
Attempting action method;
import org.openqa.selenium.interactions.Actions; public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME, true); driver.get(appURL); WebElement webElement = driver.findElement(By.xpath("//img[@class='idp-image']/..")); Actions builder = new Actions(driver); builder.moveToElement(webElement).click(webElement);
builder.perform();
Still searching for a way to successfully click the button using HtmlUnitDriver.