selenium error : - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: selenium error : (/thread-14008.html) |
selenium error : - evilcode1 - Nov-11-2018 hello all ... im trying to use selenium i keep getting this error : my code : from selenium import webdriver browser = webdriver.Firefox(executable_path=r"C:\Users\root\Desktop\geckodriver.exe") browser.get('http://www.google.com')when i run the code for the second time the error is :
RE: selenium error : - Larz60+ - Nov-11-2018 see: https://python-forum.io/Thread-Web-scraping-part-2 search for 'Headless(not loading browser):' make sure you add options to your code. RE: selenium error : - evilcode1 - Nov-11-2018 (Nov-11-2018, 09:46 AM)Larz60+ Wrote: see: https://python-forum.io/Thread-Web-scraping-part-2 this is my new code : from selenium import webdriver from selenium.webdriver.firefox.options import Options import time #--| Setup options = Options() options.set_headless(headless=True) caps = webdriver.DesiredCapabilities().FIREFOX caps["marionette"] = True browser = webdriver.Firefox(firefox_options=options, capabilities=caps, executable_path=r"C:\Users\root\Desktop\geckodriver.exe") #--| Parse browser.get('https://www.python.org/') time.sleep(2) t = browser.find_element_by_xpath('//*[@id="dive-into-python"]/ul[2]/li[1]/div[1]/pre/code/span[1]') print(t.text) browser.quit()and this is the new error :
RE: selenium error : - Larz60+ - Nov-11-2018 is this the right path for geckodriver? C:\Users\root\Desktop\geckodriver.exe" RE: selenium error : - evilcode1 - Nov-11-2018 (Nov-11-2018, 10:36 AM)Larz60+ Wrote: is this the right path for geckodriver? C:\Users\root\Desktop\geckodriver.exe" yes RE: selenium error : - snippsat - Nov-11-2018 (Nov-11-2018, 10:28 AM)evilcode1 Wrote: The executable geckodriver.exe needs to be available in the Path.The mean Windows Environment Variables Path So you look what's folder that's in Path and place geckodriver.exe there,or you can add own folder to Path(Restart) eg C:\web_drivers .
RE: selenium error : - evilcode1 - Nov-12-2018 (Nov-11-2018, 11:29 AM)snippsat Wrote:still nor work still the same last error(Nov-11-2018, 10:28 AM)evilcode1 Wrote: The executable geckodriver.exe needs to be available in the Path.The mean Windows Environment Variables Path RE: selenium error : - snippsat - Nov-12-2018 (Nov-12-2018, 10:43 AM)evilcode1 Wrote: still nor work still the same last errorIf have trouble with Path setup,just have geckodriver.exe in same folder as Scripts you run.E:\div_code\scrape |-- duck_go.py |-- geckodriver.exe # duck_go.py from selenium import webdriver from selenium.webdriver.firefox.options import Options from selenium.webdriver.common.keys import Keys import time #--| Setup options = Options() #options.add_argument("--headless") caps = webdriver.DesiredCapabilities().FIREFOX caps["marionette"] = True browser = webdriver.Firefox(firefox_options=options, capabilities=caps, executable_path=r"geckodriver.exe") #--| Parse or automation browser.get('https://duckduckgo.com') input_field = browser.find_elements_by_css_selector('#search_form_input_homepage') input_field[0].send_keys('car' + Keys.RETURN) time.sleep(3) images_link = browser.find_elements_by_link_text('Images') #Or your country name of images images_link[0].click() time.sleep(5) browser.quit() |