简体   繁体   中英

syntax for find element by css selector in selenium

my code

driver.find_element(By.cssSelector("button[type='submit']")).click()
driver.quit()

after running error

C:\Users\amalp\OneDrive\Desktop\pico.py:7: DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver=webdriver.Chrome(path) Traceback (most recent call last): File "C:\Users\amalp\OneDrive\Desktop\pico.py", line 11, in driver.find_element(By.cssSelector("button[type='submit']")).click() AttributeError: type object 'By' has no attribute 'cssSelector'

Instead of

driver.find_element(By.cssSelector("button[type='submit']")).click()

Try

driver.find_element(By.cssSelector,"button[type='submit']").click()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM