OS:
MacOS Sierra 10.12
Selenium Version:
2.53.1, 3.0.0-beta3
Facebook php-adapter
Browser:
Chrome
When i upgrade to macOS Sierra, i faced a problem that all WebDrivers methods with waiting until a condition, like $_webDriver->wait($timeout)->until(WebDriverExpectedCondition::presenceOfElementLocated($selector) doesn’t work correctly.
The problem is, if target selector is not visible or present now, WebDriver not trying to repeat check this selector again and again. WebDriver trying once and after timeout, just throws an Exception (NoSuchElementException).
The El Capitan (10.11) didn't have a problem.
Log:
12:58:13.038 INFO - Executing: [find element: By.cssSelector: .l-badge_new_wrapper #uBadgeBlock #uName])
12:58:24.008 WARN - Exception thrown
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":" .l-badge_new_wrapper #uBadgeBlock #uName"}
(Session info: chrome=53.0.2785.116)
(Driver info: chromedriver=2.24.417412 (ac882d3ce7c0d99292439bf3405780058fcca0a6),platform=Mac OS X 10.12.0 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.0.0-beta3', revision: 'c7b525d', time: '2016-09-01 14:57:03 -0700'
System info: host: 'Sakharov-MacBook-Pro.local', ip: '10.10.64.11', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12', java.version: '1.8.0_74'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=true, networkConnectionEnabled=false, chrome={chromedriverVersion=2.24.417412 (ac882d3ce7c0d99292439bf3405780058fcca0a6), userDataDir=/var/folders/lj/4bqf7t556k964jh071mxq8040000gn/T/.org.chromium.Chromium.Qfcl87}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=true, version=53.0.2785.116, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 4fb3f72ae02f3a6b4833cc3a261b21fe
*** Element info: {Using=css selector, value= .l-badge_new_wrapper #uBadgeBlock #uName}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:631)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:369)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:466)
at org.openqa.selenium.By$ByCssSelector.findElement(By.java:430)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:361)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
at com.sun.proxy.$Proxy3.findElement(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:187)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:48)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:33)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
-->
Browser Version:
53.0.2785.116
WebDriver not trying to repeat check selector’s condition again and again.
WebDriver trying once and after timeout, just throws an Exception (NoSuchElementException).
Please, fix this problem! I couldn't use WebDriver with MacOS Sierra.
Have reproduced the issue.
I'm unable to reproduce this issue using python. It may be an issue in the PHP bindings you are using.
>>> from selenium import webdriver as w
>>> from selenium.webdriver.common.by import By
>>> from selenium.webdriver.support.ui import WebDriverWait as wdw
>>> from selenium.webdriver.support import expected_conditions as EC
>>> d = w.Safari()
>>> d.get('http://google.com')
>>> wdw(d, 10).until(EC.presence_of_element_located((By.ID, 'not_present')))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
>>> wdw(d, 10).until(EC.presence_of_element_located((By.NAME, 'q')))
<selenium.webdriver.remote.webelement.WebElement (session="643440AA-03C6-4B49-B377-04A0529B7385", element="node-0D3CA905-4E23-40B9-BF0D-3740D98E3D2E")>
Please provide a complete reproducible script (Ideally in one of the language's the Selenium project supports - Java, .NET, ruby, python, javascript). To help identify where the issue may lie. We can reopen this issue when that is provided
Reproduced the issue:
OSX 10.12 Sierra
Firefox 46.0.1
Selenium 2.53
The method that brings the problem is taken from http://www.obeythetestinggoat.com/
We are using codeception with selenium web driver and have a helper method in the codeception:
public function clickAndWaitForPageToLoad($cssSelector, $timeout = 10)
{
$webDriver = $this->getWebDriver();
$elements = $webDriver->_findElements($cssSelector);
$elem = array_pop($elements);
$elem->click();
$this->waitFor(function () use ($elem) {
try {
$elem->findElements(WebDriverBy::cssSelector('body'));
return false;
} catch (StaleElementReferenceException $e) {
return true;
}
});
}
The waitFor is a simple while loop with sleep for 0.2 seconds. The same code worked flawlessly under OSX El Capitan.
The problem fix by change etc/hosts file, like:
127.0.0.1 localhost Sakharov-MacBook-Pro.local
::1 localhost Sakharov-MacBook-Pro.local
sakharovmaksim could you provide some more info? Did not catch that.
It seems it fixed the issue but why?
@sakharovmaksim's solution fixed the problem for me. To be honest I have no idea why the fix works but adding your hostname to end of local /etc/hosts entries seems to help.
1. execute hostname & copy result
2. Add hostname to the end of local IPs such as ::1 and 127.0.0.1 in /etc/hosts file
127.0.0.1 localhost YourHostNameHere.local
::1 localhost YourHostNameHere.local
Perhaps, Mac OS 10.12 has a problem with DNS...
@Everyone. Thank you so much for this. My selenium tests were running really slow. Once I followed what @sakharovmaksim did it is running fast like expected.
Thank you so much again.
Hi @sakharovmaksim ,
I did the changes you mentioned but still I get error:
Selenium::WebDriver::Error::SessionNotCreatedError:
session not created exception
and can't run my tests locally. I am using Selenium with Ruby. Do you have any idea?
Hi @payman-salimi ,
I know this problem with ChromeDriver and Chrome 54. I solved this problem as follows:
a. Install the latest ChromeDriver 2.25 linkChromeDriver
b. Change the default encoding. In your .bashrc add:
LC_NUMERIC='en_US.UTF-8’
c. Disable install encoding on startup, if you use MacOS Terminal, like in my screenshot screenshot
d. Restart Terminal
I don’t know what is wrong in Chrome 54 and ChromeDriver, but it resolve this bug...
Thanks @sakharovmaksim, you are awesome. it actually solved my problem. it was really big help.
Many thanks
Cheers.
Same problem occurred after update to Sierra 10.12.1, but @sakharovmaksim resolution helped me, thank you.
I tried the solution provided by @sakharovmaksim but still scripts are failing for me due to WebDriverWait. Moreover, Mouse hovering is not working for macOS Sierra 10.12.6 and Safaro 11.0.3.
Can any help me here please...?
Can any help me here please...?
updates to a closed issue without any environment details or reproduction steps? really?
Most helpful comment
The problem fix by change etc/hosts file, like:
127.0.0.1 localhost Sakharov-MacBook-Pro.local
::1 localhost Sakharov-MacBook-Pro.local