browser - chrome 57.0 OS - mac sierra 10.12 selenium 3.0.1, java - 1.8
Hello, can someone please help me with uploading files from the window popup in mac OS. When I click on browse button > popup opens but my scripts are not able to focus on popup. It stays on background page itself. When I tried to pass keys command + shift + g >> the small rectangular path window doesn’t open. I have already tried below solutions which didn’t help:
Here is my code with all solutions I have tried. Can you think of any better method I should use that will support execution in Jenkins as well?: (SelectAFile is the text link to upload file)
public void uploadFile (String SelectAFile, String xPathOfSelectAFile, String FileLocation) throws InterruptedException, AWTException{
driver.findElement(By.xpath(xPathOfSelectAFile)).click();
// WebElement upload = driver.findElement(By.xpath(xPathOfSelectAFile));
//upload.sendKeys("/Users/abc/Documents/xxxx/yyyy/zzz.pdf");
// Actions actions = new Actions(driver);
//actions.keyDown(Keys.COMMAND).keyDown(Keys.SHIFT).sendKeys(String.valueOf('\u0067')).perform();
//actions.moveToElement(xPathOfSelectAFile);
//actions.click();
actions.sendKeys(FileLocation);
actions.build().perform();
// driver.switchTo().activeElement();
// Alert prompt = driver.switchTo().alert();
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_META);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_G);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
actions.keyDown(Keys.COMMAND).keyDown(Keys.SHIFT).sendKeys(String.valueOf('\u0067')).perform();
- Robot.keypress
- Actions.sendkeys
- windows.switchto (window id) - in this case, both the window ids are shown same. Basically, I am not able to capture the window id of popup.
- Sikuli - I am little reluctant to use it as I am working on framework design and eventually my scripts will be shared with other teams and the screenshots that I will use in stimuli may work only for my local or only with one scenario of file uploading. I want to re-use same method at different file uploads.
- AutoIT - doesn’t work with Mac.
Thank you so much in advance.
Aucun commentaire:
Enregistrer un commentaire