如何在herf中單擊鏈接并且鏈接是字串
<a href="/pages/creation_flow/?step=profile_pic&draft_id=597215097432581&page_id=11020432423337" class="inv" id="u_0_1_sX" data-sigil="no_mpc">????</a>
uj5u.com熱心網友回復:
通常,可以通過單擊元素本身來完成。
如果此定位器正確且唯一,您可以按以下方式進行:
driver.find_element_by_xpath('//a[contains(@href,"/pages/creation_flow/?step=profile_pic")]').click()
我無法確定定位器,因為您沒有共享指向頁面或整個頁面 HTML 的鏈接。
此外,您可能需要在訪問它之前添加一些延遲。
uj5u.com熱心網友回復:
要單擊帶有????文本的元素,您可以使用以下任一定位器策略:
使用link_text:
driver.find_element(By.LINK_TEXT, "????")使用css_selector:
driver.find_element(By.CSS_SELECTOR, "a.inv[href^='/pages/creation_flow/?step=profile_pic']").click()使用xpath:
driver.find_element(By.XPATH, "//a[@class='inv' and starts-with(@href, '/pages/creation_flow/?step=profile_pic')][text()='????']").click()
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/377050.html
標籤:Python 蟒蛇-3.x python-2.7 硒 硒网络驱动程序
上一篇:串列串列中的普通串列
