【问题标题】:Python Selenium - href link is not clickable, no matter which approach I usePython Selenium - 无论我使用哪种方法,href 链接都不可点击
【发布时间】:2020-09-01 17:14:36
【问题描述】:

我正在尝试点击一个链接。但是,无论我尝试什么,它都不会使用硒执行实际操作。

我已经阅读了所有关于此的堆栈溢出主题,但似乎没有什么对我有用。 我试过了:

jcr = driver.find_element_by_id('JCRCategories')
jcr.click()

jcr = driver.find_element_by_id('JCRCategories')
webdriver.ActionChains(driver).move_to_element(jcr).click(jcr).perform()

我已经尝试通过 xpath 查找 driver.find_element_by_xpath('//*[@id="JCRCategories"]')

我尝试通过css选择器# driver.find_element_by_css_selector("a[href*='RAMore.do?product=WOS&search_mode=GeneralSearch&SID=C2JQEWUF1Ig8CKQ3H8B&qid=21&ra_mode=more&ra_name=JCRCategories&colName=WOS&viewType=raMore']").click() 找到

我也尝试过使用 WebDriverWait

    wait = WebDriverWait(driver, 10)
    element = wait.until(EC.element_to_be_clickable((By.ID, 'JCRCategories')))
    element.click()

我也尝试通过链接文本进行查找,但由于该链接文本在网站上多次出现,它不起作用。 driver.find_element_by_link_text("more options / values...").click()

这里是html

<a class="link-style1" id="JCRCategories" name="JCRCategories" href="RAMore.do?product=WOS&amp;search_mode=GeneralSearch&amp;SID=C2JQEWUF1Ig8CKQ3H8B&amp;qid=68&amp;ra_mode=more&amp;ra_name=JCRCategories&amp;colName=WOS&amp;viewType=raMore" onclick="return click_ra_more()" alt="More Refine Results" title="More Refine Results" tabindex="0" oncontextmenu="javascript:return IsAllowedRightClick(this);" hasautosubmit="true"> more options / values... </a>

感谢任何帮助或提示。请参阅网站的屏幕截图。

【问题讨论】:

  • 你遇到了什么错误?
  • 我没有收到任何错误。它只是不与元素交互
  • 你试过javascript执行器点击吗?

标签: python selenium selenium-chromedriver href


【解决方案1】:

更新:driver.find_element_by_name() 工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-27
    • 2018-02-08
    • 1970-01-01
    • 2022-08-11
    • 1970-01-01
    • 2014-01-22
    相关资源
    最近更新 更多