The script from https://www.browserstack.com/automate/python
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
desired_cap = {
'browser': 'Chrome',
'browser_version': '62.0',
'os': 'Windows',
'os_version': '10',
'resolution': '1024x768',
'name': 'Bstack-[Python] Sample Test'
}
driver = webdriver.Remote(
command_executor='http://servinc1:key@hub.browserstack.com:80/wd/hub',
desired_capabilities=desired_cap)
driver.get("http://www.google.com")
if not "Google" in driver.title:
raise Exception("Unable to load google page!")
elem = driver.find_element_by_name("q")
elem.send_keys("BrowserStack")
elem.submit()
print driver.title
driver.quit()
failed with
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='hub.browserstack.com', port=80): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))
on a system with a localhost HTTP proxy. The proxy is configured with the {http,https}_proxy
environment variables: using requests works:
import requests
r = requests.get('https://api.github.com/events')
and allowing connections to hub.browserstack.com
also works.
The aim is to use BrowserStack with a local proxy. How is this fixed?
So for now the workaround seems to be the answer: allow all connections to hub.browserstack.com to pass the firewall. E.g.
iptables -I OUTPUT 1 -p tcp --dport 443 -d hub.browserstack.com -j ACCEPT