java - Why does Webdriver no longer find elements after using Robot to download in IE -


i automating file download site using java robot in ie.

at conclusion of download, driver can no longer finds elements, including ones i've used. i've checked driver still has same window handler.

import org.openqa.selenium.webdriver; import org.openqa.selenium.firefox.firefoxdriver;  webdriver driver = new firefoxdriver();  driver.get("http://somepage");  robot robot = new robot();         webelement exportbutton = driver.findelement("//*[contains(@href,'stuff')]");  exportbutton.sendkeys("");  robot.keypress(keyevent.vk_enter); robot.keyrelease(keyevent.vk_enter);  // wait save dialog             thread.sleep(2000);  // tab on save button robot.keypress(keyevent.vk_alt); robot.keypress(keyevent.vk_n); robot.keyrelease(keyevent.vk_n); robot.keyrelease(keyevent.vk_alt); thread.sleep(2000);  robot.keypress(keyevent.vk_tab); robot.keyrelease(keyevent.vk_tab);  thread.sleep(2000);  // press enter on save button robot.keypress(keyevent.vk_enter);  // throw webdriver exception not found. driver.findelement("//*[contains(@href,'stuff')]); 

this last findelement fails, other working xpaths.

your current issue browser has lost focus web page browser dialog after robot manipulations.

generally speaking, it's not best solution download files webdriver. why need download file? going smth it? why use ie that, not chrome of firefox?

long answer perferctly explained here: https://sqa.stackexchange.com/questions/2197/how-to-download-a-file-using-seleniums-webdriver.

in short, better use 3rd party library / http client download files.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -