
我想點擊這個按鈕,我之前使用 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]
我有個問題。我應該選擇哪條路?父元素路徑,這里是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
uj5u.com熱心網友回復:
不建議將元素定位器基于元素文本,但 Facebook 站點使用多個變化的類名而沒有任何固定的元素屬性,因此在這種特定情況下,我建議使用以下 XPath 定位器:
"//span[text()='Edit post']"
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/404724.html
標籤:
