I want to click a element with onclick tag in html unit driver. But it didn't work.
I tried following method.
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();
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();
Error when using submit button:
Response message: javax.script.ScriptException: Sourced file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Method Invocation dripBoxbutton.submit : at Line: 48 : in file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : dripBoxbutton .submit ( )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:
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);
Error when using kye release:
Response 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:
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();
How to find a way to click the button in Html unit driver.