Home > Back-end >  very simple selenium auto-click for webpage does not work
very simple selenium auto-click for webpage does not work

Time:07-28

I am very new. I was trying to make an auto mail sender for practice. It opens website but not the login button. There is nothing happen after it opened.

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

import time

options = webdriver.ChromeOptions()
driver = webdriver.Chrome(
    executable_path='/Users/aidencho/practice/chromedriver', options = options)

# open a website    
url = 'https://naver.com'
driver.get(url)

# driver.maximize_window()
action = ActionChains(driver)

driver.find_element_by_css_selector('.link_login').click()
# driver.find_element_by_css_selector("#account > a").click()
# driver.find_element_by_class_name('.account > a').click()

One more thing. I saw someone doing this, and there was a completed sentence for driver.find_element_by_css_selector part even he typed only driver.find. Why not me? Would there be a setting problem?

enter image description here

CodePudding user response:

find_element_by_css_selector is deprecated. Please use find_element(by=By.CSS_SELECTOR, value=css_selector) instead.

driver.find_element(by="css selector", value='.link_login')
  • Related