I am using the selenium Chrome Driver to automate a process and also I want to restrict the user from clicking,scrolling or other suck events because the webdriver stops as soon the user performs such action.Do i need to use the JscriptDriver to add some javascript or is there any other way around?
Related
I am writing Selenium scripts to test my webpage. To simulate testing, a desktop application resets the date in the DB (as the actual process is run after the date changes).
Now I am able to call my application and click the button through Selenium by Runtime.getRuntime().exec("E:\\AutoIT\\DBReset.exe");, but I am unable to return the control to Selenium after the reset is done.
When you perform the operation by AutoIt using:
Runtime.getRuntime().exec("E:\AutoIT\DBReset.exe");
Selenium still holds the focus to the web page. So once the Windows dialog box closes, Selenium should be able to execute the next line of code.
In case Selenium complains of lost focus you can use JavascriptExecutor to gain back browser focus :
Java :
((JavascriptExecutor) driver).executeScript("window.focus();");
I have written the Selenium webdriver java code to automate the test and its working fine. But I have lot of data input to test my web and it takes time. So when i minimize the IE to do some other task while it is running the automation, it is throwing error:
org.openqa.selenium.ElementNotVisibleException: Element is not displayed
Selenium WebDriver is trying to simulate "real" users interaction with the webpage. If a person can't click on a button not currently displayed, neither can Selenium.
ElementNotVisibleException occurs when the element you want to interact with is not displayed. When you minimize the browser some of the elements are no longer visible, even though they where in maximized window.
You can add scroll using moveToElement() from Actions class every time you want to perform any action (I don't recommend it, you increase significantly the chance for errors), or find another hardware solution, like plugging in another screen, run the test on another computer etc.
According to my experience, the Internet Explorer WebDriver is very oversensitive when it comes to disturbances from a real user while running test cases. It's better to not touch anything at all. ;-)
Try Chrome! This is much more robust and also faster.
Selenium script runs as a simulator. You cannot do another work when script is running. Chrome is fast but while running script in chrome you can not do other task like any other browser. If you minimize window, you will get exception "ElementNotVisible".
I have a little app that uses selenium and works with two Chrome browsers simultaneously.
I was wondering if there is a way to restrict permission to close the browsers.
I mean I want a user to be able to ONLY close the program by using the GUI window but not turning off the browser.
I am using Selenium Webdriver for Automation, and there are few flex objects which I need to interact with. I know that Webdriver could not interact with flex objects.For that I have integrate the Webdriver with the ROBOT framework.
The problem I am facing is that I need to have focus on the current window for the mouse to detect the location of an element. If I touch My mouse while the execution is in progress, the element could not be found.
Can anyone please suggest me some alternatives to trigger a mouse event explicitly for the browser window, So that I can work on other things while my test execution is in progress?
I am using Java.
I don't believe that this is possible with Robot. However, if you use the Actions API, then you can mouse over stuff, and so forth without having the computer actually use your mouse.
Actions actions = new Actions(driver);
actions.moveToElement(someElement);
actions.click();
actions.perform();
I'm trying to write a Selenium test for a web page that uses an onbeforeunload event to prompt the user before leaving. Selenium doesn't seem to recognize the confirmation dialog that comes up, or to provide a way to hit OK or Cancel. Is there any way to do this? I'm using the Java Selenium driver, if that's relevant.
You could write a user extension (or just some JavaScript in a storeEval etc) that tests that window.onbeforeunload is set, and then replaces it with null before continuing on from the page. Ugly, but ought to get you off the page.
I've just had to do this for an application of mine where the onbeforeunload handler brings up a prompt if a user leaves a page while a document is in an unsaved state. Python code:
driver.switch_to.alert.accept()
The Java equivalent would be:
driver.switchTo().alert().accept();
If the alert does not exist, the code above will fail with a NoAlertPresentException so there is no need for a separate test to check the existence before accepting the prompt.
I'm running Selenium 2.43.0 but I think this has been doable for a while now.
In cases where I don't want the prompt to come up at all because that's not what I'm testing, I run custom JavaScript in the browser to set window.onbeforeunload to null before leaving the page. I put this in the test teardown code.
faced same problem with "beforeunlaod" event listner, LUMINUS! a chrome addon that helps me just block the event listener in the plugin thats all..
When I was confronted with limited control which I had over browser using Selenium, I turned to MozLab plugin which solved my problem if only for one browser platform.