Safari driver wont close - selenium

Safari Driver closes the browser after automated test case have run but Safari browser instance hangs and I can still see it in the open apps. Any suggestion ? At the moment I am using the following snippet to shut the browser sessions (it works for chrome). Safari Version 11.0.3 (13604.5.6). Selenium 3.11. java version "1.8.0_171".
if (System.getProperty("browser").equals("chrome") || System.getProperty("browser").equals("safari")) {
driver.quit();
}

Your mileage may vary, but I had a similar issue and found a thread here: https://github.com/appium/appium/issues/9938 where the solution (with Appium at least and also woking in my current Selenium proj) is to wait before trying to quit the driver.

Related

Chrome browser opens but nothing happens after that in selenium

I am not able to figure out why selenium API's are not executing in chrome browser, while chromedriver and chrome version is identical.
Chromedriver Version -> 91.0.4472.19
Chrome Version-> 91.0.4472.124
Output: Chrome launches and "data;" comes written in URL Bar. Nothing happens after that and test continues in running state.
I have tested with chromedriver 89,90,91,92. But nothing seems to be working.
Have anyone faced this issue ever where chrome and chromdriver version were same but browser is not executing selenoum API?
Code:
Browser name is passed from testngXML file.
ChromeOptions options = new ChromeOptions ();
options.setBinary("C\\ProgramFiles(86)\\..\\chrome.exe"); (in this location, I have chrome 91)
.......
......
System.setProperty("webdriver.chrome.driver", "src\\main\\resources\\chromedriver.exe"); (Here I have chromedriver 91)
This issue was related to somehow chrome policies. In my corporate system, there was a policy adding in chrome browser from admin (In every 1 hour) which was marking "disableChromeDevToolBar" as true. This was making the inspect (ctrl+shift+I) also greyed out.
I tried to fix this part, by changing the "disableChromeDveToolBar" value from 1 to 0 ([Windor+r-> regedit-> HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]).
This made the inspect and selenium API execution working in the chrome browser.
Note: I did not do any change in chrome browser and chromedriver. Issue was purely because of this policy.
Trying to get that policy detail from support team, if I can find out, I will update here.

Turning off w3c permanently on msedgedriver.exe

My organization, just upgraded to Version 81.0.416.53 (Official build) (64-bit) of the edge chromium browser and I am the automation engineer for it. I am having issues getting my version of Watir/Ruby to work with it I have updated the Edge Webdriver to match the version number of the browser. I was originally using the Chrome class to interact with chromium, now that no longer works, but when I switch to Edge I keep getting a w3c error when I attempt to run my ui automation scripts. There doesn't appear to be a way for me to programatically turn off the Hardware acceleration for the webdriver through the Edge class in Watir/Selenium. I have turned it off for my browser, but when I run the webdriver, it is still turned on. Is there any way for me to make this change directly in the webdriver instead of trying to change an option that doesn't exist in Watir?
I am open to other suggestions if you have them. Thank You for your time.
System:
ruby 2.5.8p224 (2020-03-31 revision 67882) [x64-mingw32]
watir(6.16.5)
selenium-webdriver (3.142.7)
Edge Chromium Version 81.0.416.53 (Official build) (64-bit)
Windows 10
Code:
require 'watir'
Selenium::WebDriver::Edge::Service.driver_path = "c:/webdriver_location/msedgedriver.exe"
client = :edge
browser = Watir::Browser.new(client)
I ran into a similar issue before. You could use the options like Chrome's in Edge Chromium. The code in ruby is like the following:
capabilities = { "edgeOptions" => {'w3c' => false} }
I'm not familiar with Watir, don't know if this syntax can be used in Watir. You could change it into the usable one in Watir.
For more detailed information, you could also refer to this thread.

Selenium Testing Safari Extension

When you attempt to run Selenium tests in a scripting context whose origin is at "safari-extension://...", the session hangs. I believe the problem is caused by extension sandboxing, which means if I get Selenium running in the same origin as the extension I am testing, it should be possible to execute selenium commands in my extension.
Question: Can I incorporate the Safari Driver into my Safari extension during testing to circumvent sandboxing?
We modified the Safari driver to navigate extension:// pages, and the problem persists. It looks like Apple blocks Selenium at the extension level :(

cannot open web instpector in chrome with selenium test

I am trying to inspect the page during an integration test, and so I have a test which I added a breakpoint in-- Once chrome launches and the test begins, the breakpoint hits, and the browser is idle.. As soon as I open the web inspector, chrome quits with the error:
Selenium::WebDriver::Error::WebDriverError:
disconnected: received Inspector.detached event
I am using Chrome version 37.0.2062.124, and ChromeDriver version 2.10.267517
This is intended. This is because the ChromeDriver uses the DevTools API to interact with Chrome.
The DevTools within Chrome has one major disadvantage and that is it only allows one debugger (whatever that might be, whether it's you or the driver itself) attached to it. Thus, once you open it, ChromeDriver cannot use it.
This is a limitation of Chrome -> the best you can do is get your test to a point where it fails, have your test close it's session but leave the browser open. Thus you have quit your test but effectively left your browser in the state of which the test failed.
This is about chrome issue(https://bugs.chromium.org/p/chromedriver/issues/detail?id=1194).
When you are running selenium program, you cannot press F12 to open dev tools manually, or it'll throw this exception sometimes.
According to the issue list, it looks like fixed, but I still meet this bug in ChromeDriver 2.29
The same problem you can visit.

Run Geb tests with chromeDriver without opening the browser

I want to run my Geb specs with chrome driver without having to watch the tests on the browser? can this be done?
P.D.: I know I can use the HtmlUnitDriver, but this driver sometimes gives my errors (caused mainly by timeouts) that the chrome driver don't.
There is currently no way to do this with Chrome, Safari, Opera or FireFox, however there are multiple options you can do. First is to pipe the "window" into a virtual frame buffer (if you're using Linux). This process will pop open the browser, only in memory. I talk about this in my blog post (http://www.ensor.cc/2011/05/maven-javascript-unit-test-using.html) during the maven pre-integration phase
The other option is to use the brand new GhostDriver. GhostDriver is a WebDriver implementation of PhantomJS which is a headless WebKit. This is WAY better than HtmlUnit but still has some features being built out. GhostDriver is currently not in Maven Central, so you will need to manually add it to the common repository. You can then use it as a WebDriver. This has worked for me with moderate success (90% of my test cases dropped in without any changes needed).
Read this first: http://blog.ivandemarino.me/2012/12/04/Finally-GhostDriver-1-0-0
Then refer to the GitHub README and code: https://github.com/detro/ghostdriver