Selenium remote connection refused using Python Fragmentation


KMK

I am trying to test the browser. Unfortunately, it doesn't seem to be able to connect to the website. Once done manually, the site opens fine in the browser.

Did I forget something? I followed the example on the shard documentation site.

my python code:

from splinter import Browser

with Browser() as browser:
    browser.visit("http://some-ip")

if browser.is_element_present_by_name("hour"):    
    browser.find_by_name("hour").fill("13")
else:
    print "No hour element"

Error message when running the script:

Traceback (most recent call last):
  File "browser-test.py", line 6, in <module>
    if browser.is_element_present_by_name("hour"):    
  File "/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/__init__.py", line 261, in is_element_present_by_name
    return self.is_element_present(self.find_by_name, name, wait_time)
  File "/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/__init__.py", line 229, in is_element_present
    if finder(selector):
  File "/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/__init__.py", line 369, in find_by_name
    return self.find_by(self.driver.find_elements_by_name, name)
  File "/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/__init__.py", line 350, in find_by
    elements = finder(selector)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 314, in find_elements_by_name
    return self.find_elements(by=By.NAME, value=name)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 677, in find_elements
    {'using': by, 'value': value})['value']
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 171, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 349, in execute
    return self._request(command_info[0], url, body=data)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 379, in _request
    self._conn.request(method, parsed_url.path, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 973, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 791, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 772, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 111] Connection refused
KMK

It turned out to be an indentation error - stupid me. Just in case anyone else made the same mistake, I made this answer as well.

from splinter import Browser

with Browser() as browser:
    browser.visit("http://some-ip")

    if browser.is_element_present_by_name("hour"):    
        browser.find_by_name("hour").fill("13")
    else:
        print "No hour element"

Related


python socket refused connection

Nicklos So I am trying to make a server program that will call the client program. If I call the server client myself from the command line, the server client works fine, but the connection is refused when the server is called. Why doesn't this work? Here is t

Python Selenium Geckodriver connection refused

salem I've spent hours trying to get Selenium to work with Python with no luck, selenium.common.exceptions.WebDriverException: Message: connection refusedhere's a sample error message I'm using :- from pyvirtualdisplay import Display from selenium import webdr

Jmeter remote connection throws "Connection refused by host"

ish I have setup distributed load testing environment using JMeter in unbundu machine. -> Master: The system runs the JMeter GUI, controlling each slave. -> Slave: A system running jmeter-server that receives commands from the master and sends requests to the

Selenium Remote Webdriver Error (Connection refused)

Ro0t777 from selenium import webdriver import sys import os cwd = os.getcwd() driver= webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.CHROME,command_executor='http://127.0.0.1:4444') driver.get('http://www.google.com') mistake: urllib.erro

Connection refused: PHPUnit Selenium in Docker

it is I am linking two containers like this (docker-compose.yml): test: container_name: test image: test ports: - "7761:80" links: - webdriver webdriver: container_name: webdriver image: webdriver "Test" contains a running

Python Selenium Geckodriver connection refused

salem I've spent hours trying to get Selenium to work with Python with no luck, selenium.common.exceptions.WebDriverException: Message: connection refusedhere's a sample error message I'm using :- from pyvirtualdisplay import Display from selenium import webdr

Python Selenium Geckodriver connection refused

salem I've spent hours trying to get Selenium to work with Python with no luck, selenium.common.exceptions.WebDriverException: Message: connection refusedhere's a sample error message I'm using :- from pyvirtualdisplay import Display from selenium import webdr

Connection refused when using Scrapy with Selenium

username I'm trying to use Scrapy with Selenium to scrape pages with dynamically generated javascript content ( http://huati.weibo.com ). I keep getting connection refused, but I'm not sure if it's what I'm doing or the server itself (in China, so maybe some k

Git remote server connection refused

User 3387949 I'm crazy about this error, after 2 days I haven't found anything in the system, and I'm sure it's easy to fix. When I try to connect to a git server using git functions, I get the following message: Could not open connection: Host does not exist

python socket refused connection

Nicklos So I am trying to make a server program that will call the client program. If I call the server client myself from the command line, the server client works fine, but the connection is refused when the server is called. Why doesn't this work? Here is t

Jmeter remote connection throws "Connection refused by host"

rattlesnake I have setup distributed load testing environment using JMeter in unbundu machine. -> Master: The system runs the JMeter GUI, controlling each slave. -> Slave: A system running jmeter-server that receives commands from the master and sends requests

Selenium remote connection refused using Python Fragmentation

KMK I am trying to test the browser. Unfortunately, it doesn't seem to be able to connect to the website. Once done manually, the site opens fine in the browser. Did I forget something? I followed the example on the shard documentation site. my python code: fr

Python Selenium Geckodriver connection refused

salem I've spent hours trying to get Selenium to work with Python with no luck, selenium.common.exceptions.WebDriverException: Message: connection refusedhere's a sample error message I'm using :- from pyvirtualdisplay import Display from selenium import webdr

Python Selenium Geckodriver connection refused

salem I've spent hours trying to get Selenium to work with Python with no luck, selenium.common.exceptions.WebDriverException: Message: connection refusedhere's a sample error message I'm using :- from pyvirtualdisplay import Display from selenium import webdr

Selenium Remote Webdriver Error (Connection refused)

Ro0t777 from selenium import webdriver import sys import os cwd = os.getcwd() driver= webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.CHROME,command_executor='http://127.0.0.1:4444') driver.get('http://www.google.com') mistake: urllib.erro

Connection refused when using Scrapy with Selenium

username I'm trying to use Scrapy with Selenium to scrape pages with dynamically generated javascript content ( http://huati.weibo.com ). I keep getting connection refused, but I'm not sure if it's what I'm doing or the server itself (in China, so maybe some k

Jmeter remote connection throws "Connection refused by host"

rattlesnake I have setup distributed load testing environment using JMeter in unbundu machine. -> Master: The system runs the JMeter GUI, controlling each slave. -> Slave: A system running jmeter-server that receives commands from the master and sends requests