I am trying to set a text to input and then click on the hidden link (sounds maybe stupid but this is a workaround for another issue). So I’ve tried something like
WebElement element = webDriver.findElement(By.cssSelector("input[id$='inputId']"));
((JavascriptExecutor) webDriver).executeScript("arguments[0].style.visibility='visible';", element);
element.sendKeys(text);
I’ve also tried
((JavascriptExecutor) webDriver).executeScript("arguments[0].setText(" + text + ")", element);
or "arguments[0].text="someText"
None of these work, test always ends with
java.lang.IllegalArgumentException: Argument is of an illegal type: $Proxy30
When I debug it, I can see that element is correctly found but I am getting this exception during execution of the script. So what am I doing wrong here?
P.S. How do I click on that link, do I have to use JS Executor too?
In semi-solid browsers, you can even search for the element via JavaScript, just run this:
Also note the use of
value. I haven’t ever seen thesetText()method ortextattribute on an element, so maybe I am mistaken. But I’m sure that input values are set by thevalueattribute.In WebDriver: