PHPUnit + Selenium 2.35 = BadMethodCallException - selenium

My English is not so good. Sorry.
I have:
PHPUnit 3.7.24
Selenium 2.35.0
I am starting selenium server:
java -jar /usr/local/bin/selenium-server-standalone-2.35.0.jar
Output:
04.09.2013 13:51:15 org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
13:51:25.373 INFO - Java: Sun Microsystems Inc. 20.45-b01
13:51:25.374 INFO - OS: Linux 3.8.0-29-generic i386
13:51:25.388 INFO - v2.35.0, with Core v2.35.0. Built from revision c916b9d
13:51:25.542 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
13:51:25.543 INFO - Version Jetty/5.1.x
13:51:25.544 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
13:51:25.545 INFO - Started HttpContext[/selenium-server,/selenium-server]
13:51:25.546 INFO - Started HttpContext[/,/]
13:51:25.567 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#dda25b
13:51:25.567 INFO - Started HttpContext[/wd,/wd]
13:51:25.571 INFO - Started SocketListener on 0.0.0.0:4444
13:51:25.577 INFO - Started org.openqa.jetty.jetty.Server#b61fd1
My simple test:
public function testTitle()
{
$this->url('/');
$this->assertEquals('My title.', $this->title());
}
Next, run phpunit test with command:
phpunit --debug functional/MainPageTest.php
Output:
PHPUnit 3.7.24 by Sebastian Bergmann.
Configuration read from /home/demyan112rv/www/boo/protected/tests/phpunit.xml
Starting test 'MainPageTest::testTitle'.
E
Time: 17.59 seconds, Memory: 2.75Mb
There was 1 error:
1) MainPageTest::testTitle
PHP Warning: include(PHPUnit_Extensions_Story_TestCase.php): failed to open stream: No such file or directory in /home/demyan112rv/www/yii/YiiBase.php on line 421
PHP Warning: include(): Failed opening 'PHPUnit_Extensions_Story_TestCase.php' for inclusion (include_path='.:/home/demyan112rv/www/boo/protected/helpers:/home/demyan112rv/www/boo/protected/widgets:/home/demyan112rv/www/boo/protected/extensions/mail:/home/demyan112rv/www/boo/protected/services:/home/demyan112rv/www/boo/protected/components:/home/demyan112rv/www/boo/protected/models:/usr/share/php:/usr/share/pear') in /home/demyan112rv/www/yii/YiiBase.php on line 421
BadMethodCallException: The command http://localhost:4444/wd/hub/session/url is not recognized by the server.
/home/demyan112rv/www/yii/test/CWeb2TestCase.php:60
/home/demyan112rv/www/boo/protected/tests/functional/MainPageTest.php:11
/home/demyan112rv/www/boo/protected/tests/functional/MainPageTest.php:11
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
And in this time in selenium server a have next output:
13:55:39.438 INFO - Executing: [new session: {browserName=firefox}] at URL: /session)
13:55:39.452 INFO - Creating a new session for Capabilities [{browserName=firefox}]
13:55:56.642 INFO - Done: /session
I have error "BadMethodCallException: The command http:/ /localhost:4444/wd/hub/session/url is not recognized by the server.". This bug fixed for 2.35 in this link , but i have 2.35 and i have this error.
How to fix this problem?
Solution (i don't may answer on my question, because my rating is less than 10.
$ whereis phpunit
phpunit: /usr/bin/phpunit /usr/bin/X11/phpunit /usr/local/bin/phpunit
I have 3 path to phphunit. I don't know, it's normal or no.
When i changed command from:
phpunit --debug functional/MainPageTest.php
to
/usr/bin/phpunit --debug functional/MainPageTest.php
it's working!!!

if you have setUp your browser launch method i.e
function setUp()
{
$this->setBrowser("*firefox");
$this->setBrowserUrl("http://www.google.com/");
}
your function should look like this
public function testTitle()
{
$this->open('/');
$this->assertEquals('My title.', $this->title());
}
I've changed $this -> url('/'); to $this -> open('/');
please try now.

Related

How to fix this Selenium Error: bind() failed: Cannot assign requested address (99)

I've installed the latest version of selenium via Docker:
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:latest
and then ran this in my python console:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", DesiredCapabilities.CHROME)
and finally checked the docker logs:
2019-04-24 19:09:26,880 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
2019-04-24 19:09:26,881 INFO supervisord started with pid 8
2019-04-24 19:09:27,865 INFO spawned: 'xvfb' with pid 11
2019-04-24 19:09:27,867 INFO spawned: 'selenium-standalone' with pid 12
19:09:28.038 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
2019-04-24 19:09:28,039 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2019-04-24 19:09:28,039 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
19:09:28.093 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2019-04-24 19:09:28.126:INFO::main: Logging initialized #247ms to org.seleniumhq.jetty9.util.log.StdErrLog
19:09:28.289 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
19:09:28.349 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
19:09:43.631 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"version": ""
}
19:09:43.633 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729#{#29}) on port 22103
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1556132983.659][SEVERE]: bind() failed: Cannot assign requested address (99)
19:09:44.266 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
19:09:44.490 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session cedc7067c0133f6492ff65dda5c7dd88 (org.openqa.selenium.chrome.ChromeDriverService)
In particular, I'm unsure of how to fix this error:
[1556132983.659][SEVERE]: bind() failed: Cannot assign requested address (99)
I'm running this on my macbook pro using Mojave with the latest version of docker, python, and selenium. I also tried using other ports aside from 4444, same result. Thanks!
We have seen that entry in the logs for a long time, however, there is no evidence it affects your tests. The message comes directly from ChromeDriver/Chrome. It is safe to ignore it.

[karate][standalone v0.9.1] Error : could not find or read file: file:xxx/yyy/zzz/./karate-config.js

I am only using the latest standalone karate jar to test my API on a docker image configured with JRE and I don't have any Java code.
This is what i have currently with the new version :
09:30:37.333 [main] INFO com.intuit.karate.netty.Main - Karate
version: 0.9.1 09:30:37.489 [main] INFO com.intuit.karate.Runner -
Karate version: 0.9.1 09:30:38.067 [ForkJoinPool-1-worker-1] WARN
com.intuit.karate - skipping bootstrap configuration: could not find
or read file: file:xxx/yyy/zzz/./karate-config.js
Here we can see it didn't find my karate-config.js file
This is what i have with the v0.9.0 :
09:48:35.829 [main] INFO com.intuit.karate.netty.Main - Karate
version: 0.9.0 09:48:35.971 [main] INFO com.intuit.karate.Runner -
Karate version: 0.9.0 09:48:36.559 [ForkJoinPool-1-worker-1] INFO
com.intuit.karate - karate.env selected environment was: preprod
Here we can see it found my karate-config.js file
Did something change on 0.9.1 ?
Thank you.
Yes something changed :( - we've been trying to fix this file resolution problem for a while. It would be great if you help us reproduce this. Since you don't use Java, can you create a zip file of the directory structure that can replicate this problem.
As a workaround, please try setting the location to the config file as per the docs:
-Dkarate.config.dir=xxx/yyy/zzz
EDIT - this is fixed and you need to re-download the binary (same version) from here: https://github.com/intuit/karate/releases/tag/v0.9.1
Okay, it works with
-Dkarate.config.dir=xxx/yyy/zzz
But only on this case :
-Dkarate.config.dir="./"
I have reproduced the error on a simplified environment, you can download this file :
Karate-Test Zip File
You just have then to execute the different .sh and see what is happening.
On the file karate-0.9.1/karate-0.9.1.sh , you have to read the comment, it works on a specific case, and it doesn't on another.
EDIT :
Another thing,
even on the 0.9.0 version case, it doesn't work when i'm not on the same directory
than the script during the execution of the script
for instance, if i'm not on the same directory, this command is not working :
./karate-0.9.0/karate-0.9.0.sh
13:01:25.764 [main] INFO com.intuit.karate.netty.Main - Karate
version: 0.9.0 13:01:25.830 [main] INFO com.intuit.karate.Runner -
Karate version: 0.9.0 13:01:26.402 [ForkJoinPool-1-worker-1] WARN
com.intuit.karate - skipping bootstrap configuration: could not find
or read file: classpath:karate-config.js
while this one is if i'm on the same directory :
./karate-0.9.0.sh 13:03:54.831 [main] INFO
com.intuit.karate.netty.Main - Karate version: 0.9.0 13:03:54.905
[main] INFO com.intuit.karate.Runner - Karate version: 0.9.0
13:03:55.421 [ForkJoinPool-1-worker-1] INFO com.intuit.karate -
baseUrl selected was: https://petstore.swagger.io

selenium server standalone: unable to create a new session with vagrant in headless mode

I am trying to run the selenium server standalone in a vagrant box, with the following command:
java -jar selenium-server-standalone-3.13.0.jar
When I click the 'create session' button at http://lab.local:4444/wd/hub/static/resource/hub.html from my host web browser. I get a unable to create a new session error message.
I ask to create a firefox browser session for which I get the driver located in /usr/local/bin/geckodriver.
Firefox has been installed on the vagrant box with sudo apt install firefox-esr.
Error log detail:
14:52:04.485 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.13.0', revision: '2f0d292'
14:52:04.486 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2018-08-09 14:52:04.564:INFO::main: Logging initialized #312ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:52:04.757 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
14:52:15.563 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "firefox"
}
14:52:15.568 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
1533819135611 geckodriver INFO geckodriver 0.21.0
1533819135614 geckodriver INFO Listening on 127.0.0.1:25541
1533819135880 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.yuusnpGo8Gw6"
1533819136508 Marionette INFO Listening on port 2828
When I run the same executable directly from my host, I get no error and the firefox session is created with success.
I try to run a X server, Xvfb as follow but this does not change anything:
Xvfb :1 -screen 0 1600x1200x16 &
export DISPLAY=:1
java -jar selenium-server-standalone-3.13.0.jar
Problem solved after switching to selenium-server-standalone-3.3.1.jar with geckodriver 0.14.0. Sessions are created with success with this configuration.
source.

Headless Chrome Circle CI - Error: spawn /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/bin/java ENOENT

I am trying to run tests in Circle CI in headless chrome.
I am using selenium server version 3.8.1 and chromedriver version 2.34
protractor_conf.js consists of chrome capabilities as:
var chromeCapabilities = {
browserName: 'chrome',
chromeOptions: {  
args: [
'headless','--show-fps-counter=false', '--remote-debugging-port=2222', '--disable-gpu'
]
}
}
My sh script includes following commands for webdriver-manager and then running tests:
./node_modules/protractor/bin/webdriver-manager clean
./node_modules/protractor/bin/webdriver-manager update --gecko false --versions.standalone 3.8.1 --versions.chrome 2.34
./node_modules/protractor/bin/webdriver-manager start &
echo "*** Run script for e2e tests"
gulp e2e
I added these in m circle.yml to install latest version of stable chrome and launched headless listening to localhost:
dependencies:
post:
# Install the latest Chrome
- curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome.deb
- sudo sed -i 's|HERE/chrome\"|HERE/chrome\" --disable-setuid-sandbox|g' /opt/google/chrome/google-chrome
- rm google-chrome.deb
before_install:
- google-chrome --headless --remote-debugging-port=2222 --disable-gpu http://localhost &
So, when I run my build now, the tests don't run at all. Logs say:
** Updating webdriver **
[05:46:11] W/file_manager - path does not exist
/home/ubuntu/pharma/test/node_modules/protractor/node_modules/webdriver-
manager/selenium
[05:46:11] I/file_manager - creating folder
/home/ubuntu/pharma/test/node_modules/protractor/node_modules/webdriver-
manager/selenium
[05:46:12] I/update - chromedriver: unzipping chromedriver_2.34.zip
[05:46:12] I/update - chromedriver: setting permissions to 0755 for
/home/ubuntu/pharma/test/node_modules/protractor/node_modules/webdriver-
manager/selenium/chromedriver_2.34
[05:46:13] I/start - java -Djava.security.egd=file:///dev/./urandom -Dwebdriver.chrome.driver=/home/ubuntu/pharma/test/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.34 -jar /home/ubuntu/pharma/test/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.8.1.jar -port 4444
[05:46:13] I/start - seleniumProcess.pid: 24198
05:46:13.642 INFO - Selenium build info: version: '3.8.1', revision: '6e95a6684b'
05:46:13.643 INFO - Launching a standalone Selenium Server
2018-01-12 05:46:13.740:INFO::main: Logging initialized #385ms to org.seleniumhq.jetty9.util.log.StdErrLog
05:46:13.781 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
05:46:13.799 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
05:46:13.801 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
05:46:13.803 INFO - Driver class not found: com.opera.core.systems.OperaDriver
05:46:13.803 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
05:46:13.803 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
05:46:13.804 INFO - Driver class not found: org.openqa.selenium.phantomjs.PhantomJSDriver
05:46:13.845 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities {browserName: internet explorer, ensureCleanSession: true, platform: WINDOWS, version: } does not match the current platform LINUX
05:46:13.845 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities {browserName: MicrosoftEdge, platform: WINDOWS, version: } does not match the current platform LINUX
05:46:13.846 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities {browserName: safari, platform: MAC, version: } does not match the current platform LINUX
05:46:13.891 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
05:46:13.892 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
05:46:13.892 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
05:46:13.893 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
05:46:13.893 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
05:46:13.902 INFO - Using the passthrough mode handler
2018-01-12 05:46:13.932:INFO:osjs.Server:main: jetty-9.4.7.v20170914
2018-01-12 05:46:13.970:WARN:osjs.SecurityHandler:main: ServletContext#o.s.j.s.ServletContextHandler#2db7a79b{/,null,STARTING} has uncovered http methods for path: /
2018-01-12 05:46:13.978:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#2db7a79b{/,null,AVAILABLE}
2018-01-12 05:46:13.998:INFO:osjs.AbstractConnector:main: Started ServerConnector#67b467e9{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2018-01-12 05:46:13.999:INFO:osjs.Server:main: Started #644ms
05:46:13.999 INFO - Selenium Server is up and running
[07:02:53] Using gulpfile ~/pharma/test/gulpfile.babel.js
[07:02:53] Starting 'set-envVars'...
[07:02:53] Finished 'set-envVars' after 245 μs
[07:02:53] Starting 'set-directories'...
[07:02:53] Finished 'set-directories' after 428 μs
[07:02:53] Starting 'e2e'...
--> Running tests using command: ./node_modules/.bin/protractor ./protractor_e2e_conf.js
Logger: Output file - /home/ubuntu/pharma/test/output/e2e/logs/console.log
[07:02:54] [INFO] Report destination: /home/ubuntu/pharma/test/output/e2e/logs/e2eTests.html
[07:02:54] [INFO] [07:02:54] I/launcher - Running 1 instances of WebDriver
[07:02:55] [INFO] [07:02:55] I/testLogger -
------------------------------------
[07:02:55] [INFO] [07:02:55] I/testLogger - [Chrome] PID: 24232
[Chrome] Specs: /home/ubuntu/pharma/test/e2e/spec/targeting/data_upload/uploadAccount_spec.js
[Chrome]
[Chrome] Logger: Output file - /home/ubuntu/pharma/test/output/e2e/logs/console.log
[Chrome] [07:02:55] [INFO] [07:02:55] I/local - Starting selenium standalone server...
[Chrome] events.js:160
[Chrome] throw er; // Unhandled 'error' event
[Chrome] ^
[Chrome]
[Chrome] Error: spawn /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/bin/java ENOENT
[Chrome] at exports._errnoException (util.js:1018:11)
[Chrome] at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
[Chrome] at onErrorNT (internal/child_process.js:367:16)
[Chrome] at _combinedTickCallback (internal/process/next_tick.js:80:11)
[Chrome] at process._tickCallback (internal/process/next_tick.js:104:9)
Versions used:
Chrome browser version: Google Chrome 63.0.3239.132
Protractor:v5.2.2
Chromedriver zip: 2.34
Selenium standalone: 3.8.1
Circle CI: 1.0
What am I missing?
Any help would be appreciated.
Solution:
The default java version installed on circle ci is 1.7. I forced it to install 1.8 jdk:
Went to circle ci build test commands and used: java --version command to check java version installed. Got v1.7 form there.
Then, I modified my Dockerfile to use jdk 8 by using: FROM openjdk:8
This would overwrite the v1.7 installed and force use 1.8 which solved my problem.

Setting up Selenium Grid - A Second Node on MAC -Registration Failure

Tried to setup a Selenium node on Mac using:
java -jar selenium-server-standalone-2.44.0.jar -role node \
-hub http://<<Hub Ip>> :4444/grid/regsiter -port 5557 \
-browser browserName=firefox,platform=MAC \
-remoteHost http://<<Remote Ip>>:5557
Error:
11:34:11.014 INFO - Adding browserName=firefox,platform=MAC
11:34:11.016 INFO - Adding browserName=chrome,platform=MAC
11:35:27.004 WARN - error getting the parameters from the hub. The
node may end up with wrong timeouts.Connect to Hub IP:80 [/Hub
IP] failed: Operation timed out 11:35:27.028 INFO - Java: Oracle
Corporation 23.25-b01 11:35:27.028 INFO - OS: Mac OS X 10.10.2 x86_64
11:35:27.038 INFO - v2.44.0, with Core v2.44.0. Built from revision
76d78cf 11:35:27.198 INFO - Default driver
org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS,
ensureCleanSession=true, browserName=internet explorer, version=}]
does not match with current platform: MAC 11:35:27.254 INFO -
RemoteWebDriver instances should connect to:
http://127.0.0.1:5556/wd/hub 11:35:27.256 INFO - Version Jetty/5.1.x
11:35:27.259 INFO - Started
HttpContext[/selenium-server/driver,/selenium-server/driver]
11:35:27.260 INFO - Started
HttpContext[/selenium-server,/selenium-server] 11:35:27.261 INFO -
Started HttpContext[/,/] 11:35:27.294 INFO - Started
org.openqa.jetty.jetty.servlet.ServletHandler#5f6b70e1 11:35:27.295
INFO - Started HttpContext[/wd,/wd] 11:35:27.299 INFO - Started
SocketListener on 0.0.0.0:5556 11:35:27.299 INFO - Started
org.openqa.jetty.jetty.Server#2c11c55b 11:35:27.346 INFO - using the
json request :
{"class":"org.openqa.grid.common.RegistrationRequest","configuration":{"register":true,"port":5556,"host":"<>","proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy","browser":"browserName\u003dfirefox,platform\u003dMAC","maxSession":5,"role":"node","hubHost":"Hub
IP","registerCycle":5000,"hub":"http://<Remote
IP:5556","remoteHost":"http://Remote Ip:5556"},"capabilities":[{"seleniumProtocol":"WebDriver","platform":"MAC","browserName":"firefox"},{"seleniumProtocol":"WebDriver","platform":"MAC","browserName":"chrome"}]}
11:35:27.347 INFO - Starting auto register thread. Will try to
register every 5000 ms. 11:35:27.347 INFO - Registering the node to
hub :http://**Remote IP:-1/grid/register 11:36:43.151 INFO -
couldn't register this node : Error sending the registration request
Your command appears to have a typo.
-hub http://<<Hub Ip>> :4444/grid/regsiter
^ ^^
here and here
Change this to:
-hub http://<<hubip>>:4444/grid/register
^ ^^
no space fix transposition
Additionally, I've always used the directive -hubUrl, not -hub. They may be synonyms, but if this solution I provided above still does not work, try also replacing -hub with -hubUrl.