Im currently making an acceptance test with the following tools:
Codeception
Selenium Webdriver
PhantomJS (as headless browser ghost)
My problem is My Tests fail when visiting a self-signed (https) page
What I've tried:
phantomjs --webdriver=5555 --ignore-ssl-errors=true --ssl-protocol=any
Adding this in capabilities phantomjs.cli.args: ["--ignore-ssl-errors=true"] in my acceptance.suit.yml
So far these options doesnt give me any luck.
Here is my acceptance.suit.yml file
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
config:
WebDriver:
url: https://myproject.com
browser: firefox
capabilities:
unexpectedAlertBehaviour: 'accept'
env:
phantom:
modules:
enabled:
- WebDriver
config:
WebDriver:
url: https://myproject.com
http_proxy: 192.1.1.1
http_proxy_port: 3000
browser: phantomjs
capabilities:
phantomjs.cli.args: ["--ignore-ssl-errors=true"]
UPDATE
This error shows up [ModuleException] WebDriver: Current url is blank, no page was opened
I don't know why this error happens since I've indicated a page. Here is a sample of my test
public function tryToTestThis(AcceptanceTester $I)
{
$I->wantTo('Test this function');
$I->amOnPage('/mypage/');
$I->see('This text');
}
An answer in Codeception would be preferable. Thanks
We figured out the cause if this problem. It was because I was running Selenium and phantomJS at the same time. (I got this idea from some tutorial.)
I was doing
java -jar selenium.jar
then I do this since it causes an error running phantomjs at port 4444 (Obviously selenium is using it) I use port 5555 instead.
phantomjs --webdriver=5555 --ignore-ssl-errors=true --ssl-protocol=any
Note: Everything works fine if not involved with https / ssl self-signed pages.
We think that codeception prioritize port 4444 and disregarding any option indicated in my phantomjs i.e. --ignore-ssl-errors=true --ssl-protocol=any thats why in fails to visit https/self-signed pages.
So basically, the fix was just running phantomjs alone without selenium.
phantomjs --webdriver=4444 --ignore-ssl-errors=true --ssl-protocol=any
Thank you
Related
I am trying to launch my serenity-Cucumber tests on a Jenkins server. Actually I'm stuck with a simple error when it launch ChromeDriver :
"IPv4 port not available. Exiting..."
My failed tests are simple : goes to a special url and verify if the url is the one expected
I'm running on maven 1.9.9 - cucumber 1.9.5 - serenity 1.9.9 - chromedriver 2.40 - jenkins 2.19.1
I run my project with command "clean verify"
I tried to set a proxy but it didn t change anything - and I tried to change chromeDriver's port without results
Is there someone who has already face this problem ?
Starting ChromeDriver 2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7) on port 4013
Only local connections are allowed.
Starting ChromeDriver 2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7) on port 9015
Only local connections are allowed.
IPv4 port not available. Exiting...
I am creating various tests with codeception - especially acceptance tests where I test the frontend or an API. The problem ist that on my local machine I am using a webserver with a port 8080 on the test server the port is 9000.
Is there a way I can dynamically set the WebDriver url? In php or another yml file. Right now the URL is set in acceptance.suite.yml and it looks like this:
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://localhost:8080/myapp'
browser: phantomjs
When I run this test on my test machine, all the tests fail (of course) because the server is running on port 9000 and not 8080.
Thanks.
I am using .env files for exactly this reason.
https://barryvanveen.nl/blog/36-environment-configuration-in-codeception-with-dotenv
I'm trying to setup selenium standalone chrome service to test my Codeception suit.
I run chrome standalone as a service:
services:
- mysql:latest
- selenium/standalone-chrome:latest
And then I setup the connections for my Codeception test uses WebDriver with an extension for WordPress:
WPWebDriver:
url: 'http://localhost'
host: 'selenium__standalone-chrome'
browser: chrome
port: 4444
restart: true
wait: 2
adminUsername: admin
adminPassword: 1234
adminUrl: /wp-admin
All other tests run well but when it comes to the suite where I use Selenium it refuses to connect:
Time: 7.55 seconds, Memory: 16.00MB
There was 1 failure:
---------
1) SampleTestCept: Test if wp is working in selenium
Test tests/php/acceptance/SampleTestCept.php
Step See "Just another WordPress site"
Fail Failed asserting that on page /
--> This site can’t be reached
localhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
Reload
DETAILS
--> contains "this site can't be reached".
Scenario Steps:
2. $I->see("This site can't be reached") at tests/php/acceptance/SampleTestCept.php:6
1. $I->amOnPage("/") at tests/php/acceptance/SampleTestCept.php:4
Any ideas of what am I doing wrong?
Use environment variable HOSTNAME, to find gitlab runner actual hostname.
I worked around this by replacing 'localhost' in your webdriver config by the ip-address of the gitlab runner. You might want to check out my blog post about running codeception tests on gitlab-ci.
Probably the issue is that you are using http://localhost url and running selenium server on separate host.
Selenium tries to connect to port 80 of its own, not of the machine which is running tests.
I'm trying for the first time to use Watir for automated browser-based testing. For all browsers I'm interested in testing with (Firefox, Chrome), I encounter timeout errors trying to connect.
Here's what I'm trying, with the errors I get in comments:
require "rubygems"
require "watir-webdriver"
browser = Watir::Browser.new :ff
# Selenium::WebDriver::Error::WebDriverError:
# unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)
browser = Watir::Browser.new :chrome
# Selenium::WebDriver::Error::WebDriverError:
# unable to connect to chromedriver http://127.0.0.1:56602
System/environment details:
Ubuntu desktop 11.04
Apache2 running on same host but only listening to port 80
gem selenium-webdriver version is 2.17.0
ruby version is 1.8.7
I'm guessing I'm doing something fundamentally wrong but I don't know enough to know where to start investigating what may be wrong. All I am aware of is that nothing is running on the ports that Selenium is trying to connect to.
What is needed for this to work?
Try the headless gem:
require 'rubygems'
require 'watir-webdriver'
require 'headless'
Headless.ly do
browser = Watir::Browser.new :ff
end
Also, on RedHat based systems, the Xvfb binary is called "Xvfb". Make a link called "xvfb" so that the headless gem finds it.
$ ln -s /usr/bin/Xvfb /usr/local/bin/xvfb
Running a Selenium 2 RemoteWebDriver server using java -jar selenium-server-standalone-2.15.0.jar.
I always get the error:
HTTP ERROR: 403
Forbidden for Proxy
RequestURI=/session
when connecting to it using the python WebDriver client:
import selenium.webdriver as webdriver
webdriver.Remote('http://localhost:4444', {})
or any other various RemoteWebDriver client I could find.
The solution was simple: Use the pathname /wd/hub
i.e.
import selenium.webdriver as webdriver
webdriver.Remote('http://localhost:4444/wd/hub', {})
Not a solution to the exactly Problem, but for people getting this error:
HTTP ERROR: 403
Forbidden for Proxy
RequestURI=/
Powered by Jetty://
This error appears e.g. if multiple instances of Selenium are running, so you need to shut it down by browsing to URL:
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
If another instance was running there should appear okok
You have another process which is bound to same port i.e 4444.
Selenium Grid by default uses port:4444.
You either need to kill the process which is bound to port:4444 or else you need to use another port(below used 5555) for your hub.
Use following in command prompt:
java -jar selenium-server-standalone-2.15.0.jar -role hub -port 5555