So I'm starting out with PHPUnit and Selenium 2
public function testHasALoginForm()
{
$this->url('/login');
$username = $this->byName('username');
$password = $this->byName('password');
$this->assertEquals('', $username->value());
$this->assertEquals('', $password->value());
}
This only happens when I call the value() method from the element and I end up getting:
1) test\view\LoginTest::testHasALoginForm
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: GET /session/fdcf0669-1d42-4a35-8e7a-29dec4a0f1e4/element/0/value
Build info: version: '2.42.1', revision: '68b415a', time: '2014-05-29 16:16:49'
System info: host: 'Something.local', ip: '192.168.1.108', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.3', java.version: '1.8.0_05'
Driver info: driver.version: unknown
Am I doing something wrong?
The ->value() method has been removed in selenium v2.42.0. The currently recommended solution is to use $element->attribute('value')
#see https://code.google.com/p/selenium/source/detail?r=953007b48e83f90450f3e41b11ec31e2928f1605
Hi i'm getting exactly the same error with roughly the same code. I am using the same version of selenium as you are.
However I did not get this error when using the 2.39.0 version.
Hence it seems to be either a regression or a deprecated use.
Related
Is it possible to run tests on Edge browser using Mink Selenium2 driver and Selenium 4 grid ?
I've tried using:
default:
suites:
default:
filters:
tags: ~#wip
paths: ['%paths.base%/storage/features']
gherkin:
cache: ~
extensions:
Behat\MinkExtension:
base_url: http://www.google.com
javascript_session: selenium2
browser_name: edge
selenium2:
capabilities:
browserName: MicrosoftEdge
browser: edge
extra_capabilities:
edgeOptions:
args:
- "--no-sandbox"
- "--disable-dev-shm-usage"
- "--headless"
- "--disable-gpu"
- "--dns-prefetch-disable"
- "--disable-setuid-sandbox"
- "--window-size=1920,1080"
- "--remote-debugging-port=9222"
But this gives me some errors saying that the DevToolsActivePort file does not exist:
13:38:41.079 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
13:38:41.086 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
13:38:41.942 INFO [NodeOptions.getSessionFactories] - Detected 8 available processors
13:38:41.970 INFO [NodeOptions.discoverDrivers] - Discovered 3 driver(s)
13:38:41.997 INFO [NodeOptions.report] - Adding Edge for {"browserName": "MicrosoftEdge"} 8 times
13:38:41.999 INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome"} 8 times
13:38:42.000 INFO [NodeOptions.report] - Adding Firefox for {"browserName": "firefox"} 8 times
13:38:42.039 INFO [Node.<init>] - Binding additional locator mechanisms: id, relative, name
13:38:42.067 INFO [LocalDistributor.add] - Added node fb3c75f0-847d-475d-88b0-dea6893c09c2 at http://172.19.0.7:4444. Health check every 120s
13:38:42.068 INFO [GridModel.setAvailability] - Switching node fb3c75f0-847d-475d-88b0-dea6893c09c2 (uri: http://172.19.0.7:4444) from DOWN to UP
13:38:42.251 INFO [Standalone.execute] - Started Selenium Standalone 4.0.0 (revision 3a21814679): http://172.19.0.7:4444
Starting MSEdgeDriver 95.0.1020.30 (09f7018e2a65a55dea3a0a261efca40ae03471ed) on port 36979
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
[1634828868.563][SEVERE]: bind() failed: Cannot assign requested address (99)
15:07:48.749 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "49c55d39b0c26898585047f89ad32f33","eventTime": 1634828868685689900,"eventName": "exception","attributes": {"driver.url": "http:\u002f\u002flocalhost:36979","exception.message": "Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: MSEdge failed to start: exited abnormally.\n (unknown error: DevToolsActivePort file doesn't exist)\n (The process started from msedge location \u002fusr\u002fbin\u002fmicrosoft-edge is no longer running, so MSEdgeDriver is assuming that MSEdge has crashed.)\nBuild info: version: '4.0.0', revision: '3a21814679'\nSystem info: host: 'dee4c77efe99', ip: '172.19.0.7', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.11'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: MSEdge failed to start: exited abnormally.\n (unknown error: DevToolsActivePort file doesn't exist)\n (The process started from msedge location \u002fusr\u002fbin\u002fmicrosoft-edge is no longer running, so MSEdgeDriver is assuming that MSEdge has crashed.)\nBuild info: version: '4.0.0', revision: '3a21814679'\nSystem info: host: 'dee4c77efe99', ip: '172.19.0.7', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.11'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:131)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:65)\n\tat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:143)\n\tat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:315)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:513)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:440)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:648)\n\tat org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:612)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base\u002fjava.lang.Thread.run(Thread.java:829)\n","exception.type": "org.openqa.selenium.SessionNotCreatedException","logger": "org.openqa.selenium.grid.node.config.DriverServiceSessionFactory","session.capabilities": "{\"browserName\": \"MicrosoftEdge\"}\n"}}```
is there any way to make this work ?
Please make sure you have
127.0.0.1 localhost
in your /etc/hosts file.
To check it, you should go to the terminal and run
sudo vi /etc/hosts
type your user password and paste
127.0.0.1 localhost
to an empty row.
Additionally, please make sure you have ChromeDriver -or the driver of the browser you intend to use- is installed and your program knows the path of ChromeDriver.
You can follow the steps explained here https://www.browserstack.com/guide/run-selenium-tests-using-selenium-chromedriver.
For DevToolsActivePort error try another workaround: add --remote-debugging-port=
I tried a different version of Selenium server with Edge, including version 4, till version 3.5; it is working fine, and above, it gives different errors. I can see that Selenium 4 is in alpha release at the Maven repository, and all other versions were released in October 2021. I would recommend that you use an earlier version for some time. You can refer to this article for the configuration of Edge with Behat Mink Selenium 2.
i know this problem is very easy for you, but at me is very difficult
i want make autotesting my web by android driver
and i found this
https://sites.google.com/a/chromium.org/chromedriver/getting-started/getting-started---android
so I installed for starting android test
selenium server - https://www.seleniumhq.org/download/
java - https://www.java.com/ko/download/windows-64bit.jsp
facebook/php-webdriver - https://github.com/facebook/php-webdriver
laravel - in console
android studio -https://developer.android.com/studio/install?hl=ko
and i did setup Environment in my computer, like below this
finally i start selenium server in my console like below
' $ java -jar selenium ~~~~~~ '
and testing is success by desktop chrome driver.
but it is failed for android driver
my code about selenium is
/ start Chrome with 5 second timeout
$host = 'http://localhost:4444/wd/hub';
$capabilities = DesiredCapabilities::android();
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
$driver->get('https://www.seleniumhq.org/');
it is fail and error code is
Unable to create session from { "desiredCapabilities": { "browserName":
"android", "platform": "ANDROID" }, "capabilities": { "firstMatch": [ {
"browserName": "android", "platformName": "android" } ] } } Build info:
version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'DESKTOP-N27RM9V', ip: '192.168.0.4', os.name: 'Windows
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211' Driver
info: driver.version: unknown
how can i solve here situation
help me,,,,,, please tell me how can solve this,,,,,
I hope you understand if I make a mistake because my english level is very low and thanks you for reading
I have a problem with web driver startup for selenium on Ubuntu 14.04.
I've already installed Oracle JDK and Selenium Standalone Server, also have no issue with running Selenium Standalone Server on Ubuntu 14.04 (I use cloud9 VDS).
But when I try to run this example an error occurs (Unable to create new service):
Fatal error: Uncaught exception 'Facebook\WebDriver\Exception\SessionNotCreatedException' with message ' in /home/ubuntu/workspace/php-web-driver-test/vendor/facebook/webdriver/lib/Exception/WebDriverException.php on line 154 Facebook\WebDriver\Exception\SessionNotCreatedException: Unable to create new service: ChromeDriverService Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z' System info: host: 'user-selenium-6138185', ip: '173.18.0.42', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.80-c9', java.version: '1.8.0_171' Driver info: driver.version: unknown in /home/ubuntu/workspace/php-web-driver-test/vendor/facebook/webdriver/lib/Exception/WebDriverException.php on line 154 Call Stack: 0.0005 234144 1. {main}() /home/ubuntu/workspace/php-web-driver-test/test-1.php:0 0.0020 307072 2. Facebook\WebDriver\Remote\RemoteWebDriver::create() /home/ubuntu/workspace/php-web-driver-test/test-1.php:11 0.0030 387224 3. Facebook\WebDriver\Remote\HttpCommandExecutor->execute() /home/ubuntu/workspace/php-web-driver-test/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126 0.1971 486960 4. Facebook\WebDriver\Exception\WebDriverException::throwException() /home/ubuntu/workspace/php-web-driver-test/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:320
Also there is some response from Selenium Server:
06:04:33.192 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.12.0', revision: '7c6e0b3'
06:04:33.194 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2018-05-16 06:04:33.330:INFO::main: Logging initialized #566ms to org.seleniumhq.jetty9.util.log.StdErrLog
06:04:33.641 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
06:04:42.085 INFO [ActiveSessionFactory.apply] - Capabilities are: Capabilities {browserName: chrome}
06:04:42.088 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
I don't know why such an error occurs, may be I have to force browser headless mode option or specify exact firefox or chrome location for web driver?
I am trying to test some javascript functionality in my Symfony Application. I tried looking at Mink for this:
http://mink.behat.org/en/latest/.
I ran a composer require for behat/mink, behat/mink-goutte-driver, and behat/mink-selenium2-driver.
I then tried to install Selenium in my ubuntu 16.04 dev enviroment.
I've got a bash script that installs java8, selenium 3.9, openjdk-8-jdk-headless, firefox, xvfb and geckodriver 0.18.0. I seem to start up the selenium server OK.
However, when I then try to start a session with Mink in my tests, I am seeing the following:
Behat\Mink\Exception\DriverException: Could not open connection: Unable to find a matching set of capabilities
Build info: version: '3.9.0', revision: '698b3178f0', time: '2018-02-05T14:56:13.134Z'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.60-linuxkit-aufs', java.version: '1.8.0_161'
Driver info: driver.version: unknown
Caused by
WebDriver\Exception\SessionNotCreated: Unable to find a matching set of capabilities
Build info: version: '3.9.0', revision: '698b3178f0', time: '2018-02-05T14:56:13.134Z'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.60-linuxkit-aufs', java.version: '1.8.0_161'
Driver info: driver.version: unknown
I'm trying to start my session in my test class like this:
// Choose a Mink driver. More about it in later chapters.
$driver = new \Behat\Mink\Driver\Selenium2Driver();
$session = new \Behat\Mink\Session($driver);
// start the session
$session->start();
I assume my problem is to do with the versions of java/firefox/selenium/ geckodriver incompatible with each other? But I can't seem to be able to fix it by trying out other versions... Is anyone able to help?
(This is my first ever question here, so let me know if if isn't great and I will try to improve it!)
I'm working on testing a site with PHPUnit (3.7.38), Selenium2 (2.43.1-standalone) and Firefox (34.0), and keep running into an intermittent problem with Selenium not being able to find tags on a page. If I take a screenshot of the error, the tag and content is there and the page looks as if it is fully loaded. There really is no AJAX to speak of on the tags I'm trying to load that would cause issue.
This seems to happen about 50% of the time and in a few specific tests. As well, it seems to gravitate towards specific lines of the test, but usually will change lines if I comment out the offending line. If I wait several minutes between tests it seems to run without error, but other than that I can't find anything that affects it.
The specific exception is:
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Unable to locate element: {"method":"tag name","selector":"h2"}
Selenium Trace:
22:32:34.544 INFO - Executing: [find element: By.tagName: h2])
22:32:35.704 WARN - Exception thrown org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"tag name","selector":"h2"}
Command duration or timeout: 220 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'andrew-xubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-43-generic', java.version: '1.7.0_65'
Session ID: e842f08c-176e-4361-859b-8fc8e67b8d5c
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=LINUX, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, webStorageEnabled=true, nativeEvents=false, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=34.0}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByTagName(RemoteWebDriver.java:417)
at org.openqa.selenium.By$ByTagName.findElement(By.java:330)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101)
at com.sun.proxy.$Proxy1.findElement(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:184)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:47)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"tag name","selector":"h2"}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'andrew-xubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-43-generic', java.version: '1.7.0_65'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///tmp /anonymous8627931668853884881webdriver-profile/extensions/fxdriver#googlecode.com/components/driver-component.js:9618:26)
at <anonymous class>.FirefoxDriver.prototype.findElement(file:///tmp/anonymous8627931668853884881webdriver-profile/extensions/fxdriver#googlecode.com/components/driver-component.js:9627:3)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///tmp/anonymous8627931668853884881webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:11612:16)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///tmp/anonymous8627931668853884881webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:11617:7)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///tmp/anonymous8627931668853884881webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:11559:5)
22:32:35.706 WARN - Exception: Unable to locate element: {"method":"tag name","selector":"h2"}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'andrew-xubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-43-generic', java.version: '1.7.0_65'
Driver info: driver.version: unknown`
Looks like upping the time Selenium waits to find elements fixed it. Adding this code to each test increases the time for each time Selenium loads a page.
function setUpPage() {
$this->timeouts ()->implicitWait ( 3000 );
}