I've an issue with my IE browser when running selenium WebDriver java scripts. For a while it will run in front of the screen, at some point of time it's going behind the screen and what ever other windows opened in the system comes to front. This is affecting the flow of the scripts run mostly. Can any one suggest a solution. Thanks !!!
There was a known issue with the IE window being pushed to the bottom of the Z-order (to the background) when doing certain operations with the IE driver. Among these were calling WebElement.click() and selecting elements in a <select> element. These issues were corrected in 2.26.0.9 of the IEDriverServer.exe. Updating both your language bindings and your IEDriverServer.exe to the latest version (2.28, at the time of this writing) will likely solve your issue.
I've solved this issue to some extend by using window.focus() method. Where ever IE window goes behind the screen, we must use it to bring it back infront of the screen. Here's the code snippet ((JavascriptExecutor)driver).executeScript("window.focus()");
Thanks :)
Related
I am trying to create a project using Selenium and ChromeDriver.
I want to know if there is a way to ensure the Selenium browser window is always displayed on top of other windows, similar to what is possible with JFrames.
So far I didn't find any solution. The only things I found were to give the window focus, but I don't want to do that.
I thought of maybe there is a way to do it through the cmd, but I don't know much about that.
We use driver.manage().window().maximize(); to maximize the browser.
I have seen few examples online that are using driver.manage().window().maximize() though it's not required to maximize the browser. (For Ex: gmail login)
Also I see on invoking browser using selenium it opens in maximized window only. Still I have to use this driver.manage().window().maximize();
Short answer: Yes.
Little longer answer: when selenium is interacting with the web page, like clicking on button or writing to text field, the interacted WebElement must be visible, or you will get exception. If you think on performance calling one time to window().maximize() is much 'cheaper' (and much less prone to errors) than scrolling to the WebElement every time.
You gave Gmail login as example, but usually you need to do more than just login in tests project.
By the way
Also I see on invoking browser using selenium it opens in maximized window only
Is not true.
It depends on your choice. If window is not maximized, probably You might not be able to find element on page. So if you need such element then it worth to maximize window.
As [pratapvaibhav19] said, it's totally depends on your choice.
There are different ways of doing this, you can open maximized Chrome windows. For Firefox and IE you can use driver.manage().window().maximize();. Alternatively you can open browser window as per your screen resolution OR in custom size.
You don't have to maximize the window.
Selenium can interact with the browser in any screen resolution, because it doesn't use the mouse or keyboard like desktop automation tools.
It's just easier to view web pages and take screenshots on bigger browser windows.
I've been using chrome driver (with selenium wedriver), so far it never caused any issue, now for some requirement it has to be in foreground with focus on it.
How can I make sure it is in the foreground?
Just immediately after navigating to your test URL, Maximize and Switch To the new window. It will come in the fore ground (provided you don't interfere with your mouse ;)
browser.navigate().to(test_URL);
browser.manage().window().maximize();
browser.switchTo().window(browser.getWindowHandle());
Finally I found the answer from one of the post, it worked for me, URL:
Bring the Firefox Browser to Front using selenium Java (Mac OSX)
I have a Java 7 application which is using Java Chromium Embedded Framework to draw html/css into two windows it launches. This works quite well in 4 of 5 PCs that I've run it on. In one case there are alignment issues with the rendered html. Successful runs include Windows 7/8/8.1. Unsuccessful run is 8.1 on an HP TouchSmart Envy, straight out of the box. Perhaps the only distinguishable differences are that this PC is new and that it has a touch screen.
As you can see, the content is shifted upward while being additionally clipped at the right and bottom sides. This is true of both windows that the application opens. What's even stranger is that mouse events (such as the :hover effects on the buttons and click events) are received in their correct position -- clicking about two inches below "Start Presentation" fires the button's click event.
Frankly, I have no idea what to try next on this. I've tried installing and uninstalling graphics-related software, adjusting the screen resolution, adding and removing the second screen, restarting the pc, and updating the onboard graphics driver.
As I have no idea what else could be causing this inconsistency, any advice in troubleshooting this issue would be fantastic.
As it turns out, this appeared to be related to the way JCEF interacts with system drivers. Going through Windows Update for the first time, restarting, and returning to the device's native resolution solved this issue.
I'm wondering if there would be any solution to show and focus on browser's tab containing a javafx 2 applet programmatically from the applet.
I don't think there's a simple solution, but who knows :)
PS : Obviously, stage.requestFocus() and stage.toFront() don't work.
No, there's absolutely no way to do this using no custom native bridge doing the job, even with a javascript bridge.
With the next versions of JavaFX neither.
And applets are not supported anymore in Chrome, so I think nobody would try that anymore.