1.) Hi, I want to log a fatal error message using log4j when the browser is closed manually, while selenium's automated testing is in process. Is there any way out for it?
2.) Also calling driver.close() or driver.quit() doesn't close my chromedriver. I have to manually close the chromedriver.exe task from the TaskManager. Do let me know the reason and a way out for this too.
Thanks in advance
Related
I'm working with Selenium, Java and Browserstack. Usually I develop in MacOS and I improve the compatibility with the remote browser. I'm trying to execute the same test cases that are working properly in MacOS, into a Windows remote machine.
The problem appears when I let a form incomplete because and I have clicked on a Cancel button to back again to the previous page. In this scenario the default chrome alert appears:
I have tried the Chrome option:
options.addArguments("--disable-notifications");
Also:
options.addArguments("--disable-popup-blocking");
And with:
prefs.put("profile.default_content_settings.popups", 0);
I know I can use a condition in the cancel button associated to the system configuration, where the selenium code accept the alert, but I'm searching an option more cleaning and easy.
Do you know any other option, capability or whatever, that could block those pop-ups but not the others?
Thank you in advance.
EDIT NOTE
It is something related with Chrome pop-ups only.
Please try
prefs.put("profile.default_content_setting_values.notifications", 2);
I am trying to prevent browser to close after my test scenario, I have tried several things found from online resources but nothing worked so far.
The goal is to prevent the browser to get closed and keep manually from a certain point, like a 'checkpoint', is there any way to do this?
I have tried :
#After("#leave_window_open")
but seems it is working only if the Scenario is failing.
is there any simple way to block this behavior, and avoiding debugging?
The browser won't close unless you call .close() or .quit(). You must have those calls somewhere... just remove them. If you are looking for a intermittent fix, just add a breakpoint where you want the script to stop. Once the run breaks, stop the execution and continue manually. I do this all the time for debugging purposes.
I am writing automation code using Selenium Webdriver Java against an application for Point of Sales systems.
When the application opens up at first there is a modal dialog which appears for the user to select an item on. This modal appears no problem when testing manually. Until just recently it also appeared when running automation.
It no longer does. The behavior is different between manual and automated runs.
I'm running against Chrome and I've set the "disable-popup-blocking" option for the Chrome driver, but it doesn't seem to be helping.
The developers also have no idea what might have changed. I am at a loss and just looking for any thoughts about where to look for clues.
Thanks.
Let me try to address your query:
The behavior is different between manual and automated runs is factually incorrect statement until & unless you are controlling the WebDriver instance with arguments.
As you mentioned there is a modal dialog which significantly means that the code for the dialog is present in the DOM. Maybe it's within​ a frame which we have to find out.
"disable-popup-blocking" option for the Chrome - The purpose of this option have nothing to do with element present in the HTML DOM.
Amidst all the confusion, the best solution may be to take help of Selenium Builder & put an end to all guesses.
Let me know if this answers your question.
i have created a selenium script in maven java, it opens a website and do some tasks, and sometimes it opens Firefox in one more new window automatically. so i want to handle such situation by closing all windows of Firefox. as you know driver.close(); will only close one focused window, so i replaced driver.close(); with driver.dispose(); to close all Firefox windows but it shows error in eclipse
The method dispose() is undefined for the type WebDriver
and i think no need to add my code here, because my question is how can i close all windows of Firefox? or how to use driver.dispose() ? Thanks
Use the .quit() method instead:
void quit()
Quits this driver, closing every associated window.
driver.quit();
Use close if you want to close just the current window or quit to closing every window associated to the driver.
I'm testing web application with Selenium Webdriver (IE). After signing off, application closes the browser, but quiting the webdriver cause crash popup for IEDriverServer.exe which hangs the flow.
Is there's a way to unload the IEDriverServer.exe after browser was closed?
You can handle this in various ways. One logic i can think of is to do getWindowHandles() and call driver.quit() based on the window count. In your case after logoff it will be null.
I had this problem with an earlier version, which version are you using? There may be a newer version of IEServerDriver than what you have. I placed mine in a directory that I then added to system PATH and have no troubles with Chromedriver or IEServerDriver.
Don't know exact solution but, for Workaround, you can try this out :
use driver.close()
If first option doesn't work then open the browser once again and use driver.quit() or driver.close().