不能' select 在 facebook 中使用 selenium 编辑按钮
Cant' select Edit button in facebook with selenium
我想点击这个按钮我之前用 XPATH 尝试成功了,但现在我不能用 XPATH 点击它。
XPATH:/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/div/div/div/div[1]/div/div[5]/div/div[2]/div[1]
我有一个问题。我应该选择哪条路? Parent 元素路径,这里是 div
或者关于这个按钮的任何元素都可以
webdriverwait
错误:
Traceback (most recent call last):
File "c:\Users\meetg\PycharmProjects\python\FB_Bot\fb_bot.py", line 54, in <module>
edit_post(browser, post_link, fb_elem_XPATH)
File "c:\Users\meetg\PycharmProjects\python\FB_Bot\bot_functions.py", line 45, in edit_post
edit_post = WebDriverWait(browser, 40).until(EC.presence_of_element_located((By.XPATH, fb_elem_XPATH['edit-post-btn'])))
File "C:\Users\meetg\PycharmProjects\python\FB_Bot\fbvenv\lib\site-packages\selenium\webdriver\support\wait.py", line 89, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:181:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:393:5
element.find/</<@chrome://remote/content/marionette/element.js:299:16
不建议将元素定位器基于元素文本,但 Facebook 站点使用多个不断变化的 class 名称,没有任何固定的元素属性,因此在这种特定情况下,我建议使用以下 XPath 定位器:
"//span[text()='Edit post']"
我想点击这个按钮我之前用 XPATH 尝试成功了,但现在我不能用 XPATH 点击它。
XPATH:/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[2]/div/div/div[1]/div[1]/div/div/div/div/div[1]/div/div[5]/div/div[2]/div[1]
我有一个问题。我应该选择哪条路? Parent 元素路径,这里是 div
或者关于这个按钮的任何元素都可以
webdriverwait
错误:
Traceback (most recent call last):
File "c:\Users\meetg\PycharmProjects\python\FB_Bot\fb_bot.py", line 54, in <module>
edit_post(browser, post_link, fb_elem_XPATH)
File "c:\Users\meetg\PycharmProjects\python\FB_Bot\bot_functions.py", line 45, in edit_post
edit_post = WebDriverWait(browser, 40).until(EC.presence_of_element_located((By.XPATH, fb_elem_XPATH['edit-post-btn'])))
File "C:\Users\meetg\PycharmProjects\python\FB_Bot\fbvenv\lib\site-packages\selenium\webdriver\support\wait.py", line 89, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:181:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:393:5
element.find/</<@chrome://remote/content/marionette/element.js:299:16
不建议将元素定位器基于元素文本,但 Facebook 站点使用多个不断变化的 class 名称,没有任何固定的元素属性,因此在这种特定情况下,我建议使用以下 XPath 定位器:
"//span[text()='Edit post']"