I'm having a problem in Selenium Webdriver.
I need to upload a file for a site. Here is what I tried:
driver.findElement(By.cssSelector(".icon-upload-cloud"))
.sendKeys(
"C:" + File.separator +
"Users" + File.separator +
"Vinicius" + File.separator +
"OneDrive" + File.separator +
"Arquivos para códigos" + File.separator +
"Logo empresa.png"
);
The problem is the button to upload is returning the error: "element is not reachable by keyboard"
.
I can solve the problem with this:
new WebDriverWait(driver, 20)
.until(
ExpectedConditions.elementToBeClickable(
By.cssSelector(".icon-upload-cloud")
)
)
.click();
But then I don't know how to upload a file because Windows opens a file selection dialog box, and I can't use sendKeys()
.
question from:
https://stackoverflow.com/questions/66052567/problem-with-element-not-reachable-by-keyboard-in-selenium-webdriver 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…