I like to use codeception acceptance test to test my PHP Application.
For this I have an acceptance.suite.yml configuration, like this:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: "http://myserver"
window_size: false # disabled in ChromeDriver
port: 9515
browser: chrome
capabilities:
chromeOptions:
args: ["--headless", "--disable-gpu"] # Run Chrome in headless mode
prefs:
download.default_directory: "/tmp"
- Yii2:
part: orm
entryScript: index-test.php
cleanup: false
When I start the test codecept run I get the following error:
[ConnectionException] Can't connect to WebDriver at http://127.0.0.1:9515/wd/hub. Make sure that ChromeDriver, GeckoDriver or Selenium Server is running.
This is strange, because url is set to http://myserver, which is not localhost.
Question: Why codecept tries to use localhost instead of http://myserver?
I also changes the port to make sure, this config-file is really used. So I found out, that the config-file is used an the port: parameter in the acceptance.suite.yml really comes form this file. Only the url: parameter seams not to have an any effect.
Any idea?
Codeception connects to WebDriver daemon, e.g. Chromedriver, and then WebDriver connects to URL.
In your case it fails to connect to WebDriver.
Have you got Chromedriver running on your computer?
If it is running on different machine, you can specify it using hostparameter.
Related
UPDATE: Problem results from on-premise runner config, works on Gitlab.com; removed all misleading parts of the question
I have an acceptance test suite for an intranet server with a domain name. I use selenium docker images for executing chrome, codeception is local.
On Gitlab.com this works like a charm, but my local Gitlab Runner won't run correctly.
MWE: https://gitlab.com/jpmschuler/mwe-gitlab-codeception-selenium-docker
The selenium config part of the test suite:
config:
WebDriver:
host: 'selenium__standalone-chrome'
browser: 'chrome'
port: 4444
What doesn't work in Gitlab CI:
myjob:
stage: test
services:
- selenium/standalone-chrome:84.0
script:
- vendor/bin/codecept run -vvv --env visualRegression --fail-fast --steps
I curld selenium and the test system and got the same response as locally, thus rules out any host resolve problems.
Nevertheless the codeception test throws for image version 3.141:
[Facebook\WebDriver\Exception\SessionNotCreatedException] session not created
from disconnected: Unable to receive message from renderer (Session info: chrome=83.0.4103.61)
and for image version 4.0.0:
[Facebook\WebDriver\Exception\SessionNotCreatedException] Unable to create session for
\<CreateSessionRequest with Capabilities {browserName: chrome}>
I find the exceptions unsettling. Neither makes sense to me as it works locally with the same selenium images. Anybody a clue where to look?
The MWE at https://gitlab.com/jpmschuler/mwe-gitlab-codeception-selenium-docker works, so I went on debugging and found it is my On-Premise-Runner:
[[runners]]
name = "its-a-me-the-broken-runner"
url = "https://git.example.com/"
token = "2c2f60a2xxxxxxxxxxxxxxxxx"
executor = "docker"
environment = ["LC_ALL=en_US.UTF-8", "DOCKER_DRIVER=overlay2"]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.docker]
tls_verify = false
image = "docker:stable"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
pull_policy = "if-not-present"
shm_size = 2097152
What could be the problem here?
Here's the situation:
machineA has Protractor, Selenium, WebDriver, etc. installed.
machineB has all source code including tests and server running source code, but no Protractor, Selenium, etc
environment is Linux on both machines
How can I run the Protractor command on machineA so that it points to the spec on machineB?
ie. How to get a local Protractor command to point to a remote spec?
You need to provide seleniumAddress in your config file and make sure directConnect option is commented or value should be false.
Start webdriver on machineA through webdriver-manager start
exports.config = {
baseUrl: 'http://example.com/',
seleniumAddress: 'https://<machineA IP addess>:4444/wd/hub',
//directConnect:true,
...
}
I want to use the protractor to run the tests on the selenium grid, which runs on :
http://<ip_address>:4444/
In my config file I have:
seleniumAddress: "http://32.14.98.73:4444/wd/hub",
When I run the test, they are run locally and start the browser on the local system. ? Anything else is needed for this to work ?
In logs I have:
[18:20:05] I/direct - Using ChromeDriver directly...
[18:20:05] I/launcher - Running 1 instances of WebDriver
Change your config file for object directConnect to directConnect:false. For detailed understanding on directConnect and seleniumAddress refer the below link Difference running Protractor with/without Selenium?
I've worked with Cucumber and Watir before and, when I wanted to run a test in firefox, I just created a new browser instance the following way:
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 60
$browser = Watir::Browser.new :firefox , profile: $profile, :http_client => client
Now I am using Behat, and when I want to run a test in Firefox, I have to define the Selenium parameters in behat.yml first:
Behat\MinkExtension:
base_url: 'http://test.com'
sessions:
default:
goutte: ~
javascript:
selenium2:
wd_host: http://localhost:4444/wd/hub
But I also have to run the Selenium standalone server in a separate terminal window:
java -jar selenium-server-standalone-2.44.0.jar
And leave it running in background.
My question is: is there any way to make Mink work like Watir? Launching a new browser instance when a test is run and killing it after it finishes without having to worry about running the service in background?
Trying to use Codeception Web Driver and Selenium to emulate ajax through an acceptance test. I was using PhpBrowser but when I was having issues with Ajax my friend suggested WebDriver.
After enabling it and downloading the selenium (and running it) I get the following error.
[WebDriverCurlException]
Curl error thrown for http POST to http://127.0.0.1:4444/wd/hub/session
with params: {"desiredCapabilities":{"browserName":"googlechrome"}}
Failed to connect to 127.0.0.1 port 4444: Connection Refused
I made sure I was running selenium on port 4444.
java -jar selenium-server.jar -port 4444
acceptance.suite.yml below
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
- REST
config:
WebDriver:
url: 'http://life1605.dev'
browser: googlechrome
REST:
url: 'http://life1605.dev'
I had the same problem, with the exact same error message. For some strange reason, it looked like starting the selenium server from command line did not work.
My solution turned out to be manually opening the selenium server through Windows Explorer, right click on the file, choose Open with -> Java Platform SE Binary.
Took me almost 3 hours to figure it out, so I hope this helps somebody.
I had this problem and it turned out a new version of Firefox was incompatible with the addon that Selenium uses to communicate with Firefox.
When you start your tests you should see the new Firefox window appear, and have 30 seconds or so before it goes away again. Within this time, if you type about:addons into the URL field and then click on "Extensions", you should see the "Firefox WebDriver" addon there, and it should be enabled.
For me it was disabled as it was incompatible with the latest Firefox version. So the solution in this case was to either downgrade Firefox or wait for an updated Selenium.
Note that the addon is only installed in the Firefox instance under test, so you won't see it when you use Firefox outside of Selenium.
I had this same problem, I forgot to run phantom.js before trying to do any browser tests. I ran phantomjs and it worked.
I had this problem, and then I remembered that I need to run Xvfb -ac :0 -screen 0 1280x1024x16 & after every Homestead reload (before running Dusk tests).
Then Dusk works instead of saying:
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown
for http POST to /session with params:
{"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}
Operation timed out after 30000 milliseconds with 0 bytes received
See https://stackoverflow.com/a/42630737/470749