N
N
NitroDesktop2020-06-01 20:22:25
Python
NitroDesktop, 2020-06-01 20:22:25

How to fix selenium - webdriver does not start and writes errors in everything except chrome and mozilla, how can I fix it?

Chrome and mozilla works, but the rest does not!

from selenium import webdriver

from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.microsoft import IEDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager
from webdriver_manager.opera import OperaDriverManager

def screen_inserting(brw,sized,url):
    sized=sized.split(",")
    if brw=="chrome":
        driver = webdriver.Chrome(ChromeDriverManager().install())
        driver.set_window_size(sized[0],sized[1])
        driver.get(url)
        driver.save_screenshot("screen.png")
        # element = driver.find_element_by_tag_name('body')
        # element.screenshot("screen_new.png")
        driver.quit()
    elif brw=="firefox": 
        driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
        driver.set_window_size(sized[0],sized[1])
        driver.get(url)
        driver.save_screenshot("screen.png")
        driver.quit()
    elif brw=="iexplore":    
        driver = webdriver.Ie(IEDriverManager().install())
        driver.set_window_size(sized[0],sized[1])
        driver.get(url)
        driver.save_screenshot("screen.png")
        driver.quit()
    elif brw=="opera":
        driver = webdriver.Opera(executable_path=OperaDriverManager().install())
        driver.set_window_size(sized[0],sized[1])
        driver.get(url)
        driver.save_screenshot("screen.png")
        driver.quit()
    elif brw=="edge":
        driver = webdriver.Edge(EdgeChromiumDriverManager().install())
        driver.set_window_size(sized[0],sized[1])
        driver.get(url)
        driver.save_screenshot("screen.png")
        driver.quit()


Errors like this:
Traceback (most recent call last):
  File "d:\python\screens.py", line 121, in <module>
    screen_inserting(brw,brw_size,urls)
  File "d:\python\screens.py", line 96, in screen_inserting
    driver = webdriver.Ie(IEDriverManager().install())
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\webdriver_manager\microsoft.py", line 25, in install
    return self.download_driver(self.driver)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\webdriver_manager\manager.py", line 44, in download_driver
    path = self.__download_and_save_driver_to_cache(driver, driver_version)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\webdriver_manager\manager.py", line 32, in __download_and_save_driver_to_cache
    response = download_driver(driver.get_url(driver_version))
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\webdriver_manager\utils.py", line 58, in download_driver
    log(f"Trying to download new driver from {url}")
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\webdriver_manager\logger.py", line 12, in log
    level = int(log_level)
ValueError: invalid literal for int() with base 10: 'None'

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question