首页 > 解决方案 > 如何在 Chrome 选项 python selenium 中通过 xpath 找到元素

问题描述

我面临着一些困难,(它还没有完成)

import webbrowser
import time

url1 = 'https://www.youtube.com/watch?v=W8KRzm-HUcc'
chrome_path = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chrome_path))
webbrowser.get('chrome').open_new_tab(url1)
time.sleep(12)***.find_element_by_xpath('//*[@id="search"]').click()***

如何在不编写“Driver.find_element_by_xpath”的情况下通过 xpath 找到元素,因为每当我不使用“Driver.find_element_by_xpath”时,我都会收到此错误:

**attributeerror 'nonetype' object has no attribute 'find_element_by_xpath'**

感谢您的帮助,我是编码新手,但我仍然没有得到一些东西......

标签: python

解决方案


推荐阅读