I have an element with this outerHtml -
<input class="inp-text ps-component ng-valid-maxlength ng-touched ng-pristine ng-empty ng-invalid ng-invalid-required" ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 200, 'blur': 0 } }" required="required" maxlength="100" ng-model="model.name"/>
I had tried -
driver.findElement(By.cssSelector("input"));
can find this element, but when I try to do
driver.findElement(By.cssSelector("input")).sendKeys("something");
java tell me that the element is not visible
exception
driver.findElement(By.cssSelector("input")).click();
don't work too.
How to send some keys in this input element?
I found a part of solution. click() work if use it:
WebElement input = driver.findElement(By.cssSelector("input"))
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", input);
But I still don't understand how to send keys in it.
Try using explicit wait with Expected Conditions to make sure the element is visible before interacting with it
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input")));
element.sendKeys("something");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With