Python 3.x 如何单击下拉列表?

Python 3.x 如何单击下拉列表?,python-3.x,selenium,selenium-webdriver,drop-down-menu,dropdown,Python 3.x,Selenium,Selenium Webdriver,Drop Down Menu,Dropdown,代码 错误 如果错误代码更改为 driver.find_element((By.XPATH, "//li[contains(@class,'ellipsis1')][1]")).click() 错误: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath&qu

代码

错误

如果错误代码更改为

driver.find_element((By.XPATH, "//li[contains(@class,'ellipsis1')][1]")).click()
错误:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate 
element: {"method":"xpath","selector":"//li[contains(@class,'ellipsis1')][1]"}
完整代码

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time
import pyperclip
import re



id = 'YOUR_ID' # 네이버 아이디
ps = 'YOUR_PASS' # 네이버 비밀번호

driver = webdriver.Chrome('C:\stockauto\selenium\chromedriver.exe') #드라이브 크롬으로 설정
driver.get('https://nid.naver.com/nidlogin.login') # 네이버 로그인 창으로 이동
time.sleep(1) # 1초 대기


tag_id = driver.find_element_by_name('id') # id 입력할 곳을 tag_id 변수로 저장
tag_pw = driver.find_element_by_name('pw') # pw 입력할 곳을 tag_pw 변수로 저장
tag_id.clear() # tag_pw 창에 있는 정보를 지움
time.sleep(1) # 1초 대기

tag_id.click() # tag_id창 클릭
pyperclip.copy(str(id)) # id 클립보드에 복사
tag_id.send_keys(Keys.CONTROL, 'v') # 붙여넣기
time.sleep(1) # 1초 대기

# pw 입력
tag_pw.click() # tag_pw창 클릭
pyperclip.copy(str(ps)) # pw 클립보드에 복사
tag_pw.send_keys(Keys.CONTROL, 'v') # 붙여넣기
time.sleep(1) # 1초 대기
pyperclip.copy('') # 클립보드 초기화

# 로그인 버튼을 클릭합니다
driver.find_element_by_id('log.login').click() # 로그인 버튼 클릭
time.sleep(2) # 2초 대기

driver.get('https://admin.blog.naver.com/'+str(id)) # 검색어, 최신순으로 검색
driver.implicitly_wait(5) # 5초 암묵적 대기
print("코드 시작")
driver.find_element_by_id("buddylist_config_anchor").click()
print("1")
time.sleep(1)
driver.find_element((By.XPATH, "//li[contains(@class,'ellipsis1')][1]")).click()
time.sleep(1)
我是一个刚开始编码的初学者。
非常感谢您的帮助。

您是否尝试使用完整的Xpath

你必须再检查一件事。有时导航器在检测到宏时会阻止访问

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate 
element: {"method":"xpath","selector":"//li[contains(@class,'ellipsis1')][1]"}
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time
import pyperclip
import re



id = 'YOUR_ID' # 네이버 아이디
ps = 'YOUR_PASS' # 네이버 비밀번호

driver = webdriver.Chrome('C:\stockauto\selenium\chromedriver.exe') #드라이브 크롬으로 설정
driver.get('https://nid.naver.com/nidlogin.login') # 네이버 로그인 창으로 이동
time.sleep(1) # 1초 대기


tag_id = driver.find_element_by_name('id') # id 입력할 곳을 tag_id 변수로 저장
tag_pw = driver.find_element_by_name('pw') # pw 입력할 곳을 tag_pw 변수로 저장
tag_id.clear() # tag_pw 창에 있는 정보를 지움
time.sleep(1) # 1초 대기

tag_id.click() # tag_id창 클릭
pyperclip.copy(str(id)) # id 클립보드에 복사
tag_id.send_keys(Keys.CONTROL, 'v') # 붙여넣기
time.sleep(1) # 1초 대기

# pw 입력
tag_pw.click() # tag_pw창 클릭
pyperclip.copy(str(ps)) # pw 클립보드에 복사
tag_pw.send_keys(Keys.CONTROL, 'v') # 붙여넣기
time.sleep(1) # 1초 대기
pyperclip.copy('') # 클립보드 초기화

# 로그인 버튼을 클릭합니다
driver.find_element_by_id('log.login').click() # 로그인 버튼 클릭
time.sleep(2) # 2초 대기

driver.get('https://admin.blog.naver.com/'+str(id)) # 검색어, 최신순으로 검색
driver.implicitly_wait(5) # 5초 암묵적 대기
print("코드 시작")
driver.find_element_by_id("buddylist_config_anchor").click()
print("1")
time.sleep(1)
driver.find_element((By.XPATH, "//li[contains(@class,'ellipsis1')][1]")).click()
time.sleep(1)