Setup:
I'm getting this error when using selenium in heroku:
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
I googled but didn't have luck. The error happens at the last line of this code.
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
UA = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36' \
'(KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
DRIVER_PATH = '/app/.chromedriver/bin/chromedriver'
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = '/app/.apt/usr/bin/google-chrome'
chrome_options.add_argument(f'--user-agent={UA}')
chrome_options.add_argument(f'--proxy-server=http://my_private_proxy.com:my_port')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
chrome = webdriver.Chrome(executable_path=DRIVER_PATH, options=options)
Selenium is a chemical element with symbol Se and atomic number 34. It is a nonmetal with properties that are intermediate between the elements on either side in the periodic table, sulfur and tellurium.
If you want to create quick bug reproduction scripts, create scripts to aid in automation-aided exploratory testing, then you want to use Selenium IDE; a Chrome, Firefox and Edge add-on that will do simple record-and-playback of interactions with the browser. Simon is stepping down as lead of the Selenium project.
Good natural food sources of selenium include: Whole foods are the best sources of selenium. The mineral may be destroyed during processing. What are the risks of taking selenium? Side effects. Taken at normal doses, selenium does not usually have side effects.
Selenium is most commonly found as an impurity, replacing a small part of the sulfur in sulfide ores of many metals. In living systems, selenium is found in the amino acids selenomethionine, selenocysteine, and methylselenocysteine.
This error message...
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
...implies that the ChromeDriver in Headless mode was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Some information regarding the versions of the binaries you are using would have helped us to analyze the error in a better way. However, this issue of urllib3 can be obseved due to several reasons as mentioned below:
--disable-gpu
is not needed as in the discussion Headless: make --disable-gpu flag unnecessary [email protected] mentioned:This flag is no longer necessary on Linux or macOS. It will become unnecessary on Windows as soon as SwiftShader fails an assert on Windows in headless mode gets fixed.
You can find a detailed discussion in Lost UI shared context : while initializing Chrome browser through ChromeDriver in Headless mode
Additionally, you can add the argument --disable-dev-shm-usage
to overcome limited resource problems:
chrome_options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
You can find a detailed discussion on --disable-dev-shm-usage
in the discussion org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
@Test
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With