Quality is delighting customers
Tried with Robot class and sendKeys methods, but it is not successful.
Can you guys help me please.
Tags:
You should not be using Robot when it comes to browser automation at all because when it comes to parallel test execution your keyboard-based input will require browser being in focus otherwise the input will go to another (wrong) window.
Instead of using Robot you should rather locate the relevant input type=file using suitable locator strategy and then provide full path to the file you want to upload via WebElement.sendKeys() function
WebElement fileUpload = driver.findElement(By.xpath("//input[@type='file']"));
fileUpload.sendKeys("c:/somefolder/somefile.png");
Tried with above code, but it is throwing error:
java.lang.IllegalArgumentException: Cannot find elements when the XPath is null.
java.lang.IllegalArgumentException: Cannot find elements when the XPath is null.
at org.openqa.selenium.By$ByXPath.<init>(By.java:339) at org.openqa.selenium.By.xpath(By.java:92)
© 2021 Created by Quality Testing.
Powered by