硒:如何使用标签中的文本单击href链接

时间:2019-01-26 11:21:49

标签: python selenium

我尝试使用文本单击链接:

<td class="td_trdmrk_row"><a href="&#10;&#9;&#10;&#9;&#10;&#9;/wps/portal/!ut/p/c5/jY5NDoIwGESP1E9oKtsCsUVoBbRS2BASjYHITyIB4fTCAURnlpM3eShDS5tiKB9FX7ZN8UQaZST3PBpyn-3gZAgAaklFD0diADOXPSW5wyjH-wCAydgBD9vY4Mw2wDP_oeFLKPygE6QB5-fK6sTU62B2hks1R--XG5nS9ScRJCCkDm_XWNnUHaOU7BYmW1-3jNd9w0nytr6jrlZq6Pj4AXLkpM8!/dl3/d3/L0lDU0lKSkthWWtLQ2xFS0NsRUpJL29Eb2dBRUlRaGpCS0VRQUNBRVpDZ0dRNEtRcGNFclN0Y1ZhQ0FHTUEvNEMxYjlXX05yeFFERVNaSUpSQ2t5WVNoRVJJX0FBISEvN19JSUFQSEtHMTBPMk0wMEE4TlVBRko2MkdTNS80MDk3NjAyMTAzNTcvYWNOYW1lL2NsaWNrUmVnaXN0ZXIvcmVnTmFtZS9SVVRN/">Реестр товарных знаков и знаков обслуживания</a></td>

我使用下一个代码从此link获取信息:

def render_page(path, path_to_chromedriver):

    caps = DesiredCapabilities.PHANTOMJS
    caps["phantomjs.page.settings.userAgent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
    driver = webdriver.Chrome(path_to_chromedriver,
                          desired_capabilities=caps)
    driver.get(path)
    time.sleep(3)
    link = driver.find_element_by_link_text("Реестр товарных знаков и знаков обслуживания")
    link.click()
    r = driver.page_source

    return r

r = render_page(path_registered)
print(r)

但是它返回:

WebDriverException: Message: unknown error: Element <a href="&#10;&#9;&#10;&#9;&#10;&#9;/wps/portal/!ut/p/c5/jY5NDoIwGESP1E9oKtsCsUVoBbRS2BASjYHITyIB4fTCAURnlpM3eShDS5tiKB9FX7ZN8UQaZST3PBpyn-3gZAgAaklFD0diADOXPSW5wyjH-wCAydgBD9vY4Mw2wDP_oeFLKPygE6QB5-fK6sTU62B2hks1R--XG5nS9ScRJCCkDm_XWNnUHaOU7BYmW1-3jNd9w0nytr6jrlZq6Pj4AXLkpM8!/dl3/d3/L0lDU0lKSkthWWtLQ2xFS0NsRUpJL29Eb2dBRUlRaGpCS0VRQUNBRVpDZ0dRNEtRcGNFclN0Y1ZhQ0FHTUEvNEMxYjlXX05yeFFERVNaSUpSQ2t5WVNoRVJJX0FBISEvN19JSUFQSEtHMTBPMk0wMEE4TlVBRko2MkdTNS80MDk3NjA1MDE4NDYvYWNOYW1lL2NsaWNrUmVnaXN0ZXIvcmVnTmFtZS9SVVRN/">...</a> is not clickable at point (663, 623). Other element would receive the click: <html lang="ru_RU">...</html>

我该如何解决?

1 个答案:

答案 0 :(得分:2)

解决该问题

0