Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python, error with web driver (Selenium)

    import time
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome()
driver.get('http://arithmetic.zetamac.com/game?key=a7220a92')
element = driver.find_element_by_link_text('problem')
print(element)

I am getting the error:

FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'

I am not sure whythis is happening, because I imported selenium already.

like image 779
imfat123 Avatar asked Oct 08 '16 03:10

imfat123


People also ask

Can you use Python with Selenium WebDriver?

Selenium is an open source automation testing tool that supports a number of scripting languages like Python, C#, Java, Perl, Ruby, JavaScript, etc.

How do you handle no such element exception in Selenium Python?

1. Change in source code of the webpage. It's possible that the source code of the webpage may have been changed since the last time you accessed it. Change your code according to the new source to solve the issue.

What is WebDriver exception in Selenium?

An exception object is created when an exception is encountered, which contains debugging information such as the line number, the type of Exception, the method hierarchy. Once the exception object is created and handed over to the runtime environment, this process is called “Throwing the Exception.”


1 Answers

Either you provide the ChromeDriver path in webdriver.Chrome or provide the path variable

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
driverLocation = 'D:\Drivers\chromedriver.exe' #if windows
driver = webdriver.Chrome(driverLocation) 
driver.get('http://arithmetic.zetamac.com/game?key=a7220a92')
element = driver.find_element_by_link_text('problem')
print(element)
like image 178
Vardhman Patil Avatar answered Oct 19 '22 23:10

Vardhman Patil