Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NameError: name 'By' is not defined (selenium)

Tags:

python-3.x

I get this error in my python code:

Traceback (most recent call last):
File "/Users/user/Batch-image-compression/compress_pic.py", line 54, in <module>

**input_box = driver.find_element(By.XPATH,'//input[@class="_2zg9i"]')**

NameError: name 'By' is not defined

In my script I have:

from selenium.webdriver.common import By

The showing error :

from: can't read /var/mail/selenium.webdriver.common

like image 796
ivan Avatar asked Jun 08 '26 23:06

ivan


1 Answers

Use this line instead:

from selenium.webdriver.common.by import By
like image 64
Z Constantine Avatar answered Jun 11 '26 22:06

Z Constantine