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
Related
While running simple selenium test in google chrome, got below error. (Windows 10)
Starting ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590####-refs/branch-heads/3770#{#XXXX}) on port XXXXX
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
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'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.
While running my simple selenium automation script on chrome broswer, i am getting below mentioned error. The script runs fine on firefox browser. Mine is HTTPS website.
No connection could be made because the target machine actively
refused it. - connect(2) for "127.0.0.1" port 9515
(Errno::ECONNREFUSED)
IDE: Ruby Mine 7.1.4
Chrome Browser: 54.0.2840.71 m (64-bit)
Script:
require "selenium/webdriver"
driver = Selenium::WebDriver.for :chrome
driver.get('http://google.com')
I had same problem as yours after Windows Update last time.
I updated chromedriver.exe from v2.9 to v2.24 and put it on bin directory where ruby installed, then it's fixed.
I'm using Steak + Capybara for acceptance testing and rack-ssl for SSL enforcement, now, when I tried to run the test suite, I've got the error message
(Error code: ssl_error_rx_record_too_long)
Any idea how to make it work?
Capybara launches plain app server (Mongrel/Webrick), which doesn't support SSL. To get SSL environment on your local machine you'd have to setup something like nginx or Apache with mod_ssl and mod_proxy to accept SSL connections and proxy plain HTTP requests to your devel server.
You can then launch it in your test environment setup, and in your tests to navigate to this SSL server rather than app server itself.
Caveats:
To set up "ssl server" you will have to create a self-signed SSL certificate. A browser does not trust it by default until you add it to the list of exceptions. AFAIR Capybara selenium driver creates a new Firefox profile each time, so it will reject your SSL cert. You might have to purchase a "real" certificate.
Capybara launches its internal server on random available port, you will need to change it. I recall writing something along the lines of:
Capybara::Server.class_eval do
def find_available_port
#port = 3000
end
end