In automation, I'm a complete zero. I tried to reproduce examples from Learning Selenium Testing Tools with Python, but I get the following errors:

Traceback (most recent call last): File "F:/projects/Selenium/Python/sample1/searchproducts.py", line 4, in <module> driver = webdriver.Firefox() File "C:\Users\Антон\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 80, in __init__ self.binary, timeout) File "C:\Users\Антон\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 52, in __init__ self.binary.launch_browser(self.profile, timeout=timeout) File "C:\Users\Антон\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser self._wait_until_connectable(timeout=timeout) File "C:\Users\Антон\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 99, in _wait_until_connectable "The browser appears to have exited " selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details. 

Here is the test test code:

 from selenium import webdriver # create a new Firefox session driver = webdriver.Firefox() driver.implicitly_wait(30) driver.maximize_window() # navigate to the application home page driver.get('http://demo-store.seleniumacademy.com/') # get the search textbox search_field = driver.find_element_by_name('q') search_field.clear() # enter search keyword and submit search_field.send_keys('phones') search_field.submit() # get all the anchor elements which have product names displayed # currently on result page using find_elements_by_xpath method products = driver.find_elements_by_xpath("//h2[@class='product-name']/a") # get the number of anchor elements found print ('Found ' + str(len(products)) + ' products:') # iterate through each anchor element and # print the text that is name of the product for product in products: print (product.text) # close the browser window driver.quit() 

Guglezh did not give any result. Please tell me what to fix.

  • update selenium, use firefox 45 or lower - vadim vaduxa
  • Beat "selenium.common.exceptions.WebDriverException: If you specified a log_file in the Firefox Binary constructor, check in google translate. - Nakilon
  • @Nakilon and what? it doesn't tell me anything. I do not understand either in binary or in logs. Above, I wrote that automation is zero. - ToshiDono
  • @vadimvaduxa thanks - it helped. - ToshiDono
  • Obviously, you should have driven Google into "how to specify a log_file in the FirefoxBinary constructor". The fact that you are zero is no excuse for not wanting to read error messages. - Nakilon

0