简体   繁体   English

下拉列表 selenium python

[英]Drop down list selenium python

Im trying to use a drop down list whit selenium:我正在尝试使用 selenium 的下拉列表:

browser.get('https://account.mail.ru/signup?from=main&rf=auth.mail.ru')
day = Select(browser.find_element_by_xpath('/html/body/div[1]/div[3]/div[3]/div/div/div/form/div[5]/div[2]/div/div[1]/div/div/select'))
dayDD=Select(day)
dayDD.select_by_index(3)

but i always get this error:但我总是得到这个错误:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[1]/div[3]/div[3]/div/div/div/form/div[5]/div[2]/div/div[1]/div/div/select"}

I dont know why it can't find xpath since i get it same way i get all my other xpaths我不知道为什么它找不到 xpath 因为我得到它的方式与我得到所有其他 xpath 的方式相同

could you attach DOM page screen with list of elements?你能附上带有元素列表的 DOM 页面屏幕吗?

At this stage I see 2 posibilities:在这个阶段,我看到了 2 个可能性:

- Elements are not loaded - 未加载元素

Use implicit or explicit wait: https://www.geeksforgeeks.org/waits-in-selenium-python/?ref=rp使用隐式或显式等待: https://www.geeksforgeeks.org/waits-in-selenium-python/?ref=rp

- Xpath is not correct - Xpath 不正确

Maybe learn how to use relative path: https://www.tutorialspoint.com/xpath/xpath_relative_path.htm也许学习如何使用相对路径: https://www.tutorialspoint.com/xpath/xpath_relative_path.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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