8

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

ZF007
  • 3,708
  • 8
  • 29
  • 48
ivan
  • 89
  • 1
  • 1
  • 2
  • Have you checked the seleniuum installation logs? Looks like incorrect install of the library. – ZF007 Nov 08 '21 at 12:12
  • The second error seems unrelated, and is a duplicate of https://stackoverflow.com/questions/16069816/getting-python-error-from-cant-read-var-mail-bio – tripleee Jun 13 '22 at 04:57

1 Answers1

13

Use this line instead:

from selenium.webdriver.common.by import By
ouflak
  • 2,458
  • 10
  • 44
  • 49
Z Constantine
  • 131
  • 1
  • 3