-1

I am newbie about python selenium and I am trying to click on a button which has the following html structure:

 <a href="javascript:doPage('2');">2</a>
    -->
    <a href="#doPage2" onclick="javascript:doPage('2');">2</a>
    <img src="/images/common/divisionLine.gif" alt="" />
    <!--
    <a href="javascript:doPage('3');">3</a>
    -->
    <a href="#doPage3" onclick="javascript:doPage('3');">3</a>
    <img src="/images/common/divisionLine.gif" alt="" />

I want to click hyperlink name "2" or "3" like below code. But it does not work.

wait(driver, 5).until(EC.element_to_be_clickable((By.XPATH,"//a[@onclick=\"javascript:doPage('2');\"]"))).click()

When I run my python code, I got below error comment.

selenium.common.exceptions.WebDriverException: Message: unknown error: Element is not clickable at point (577, 821)

Any thoughts which can point me in the right direction would be great. Thanks.

JeffC
  • 22,180
  • 5
  • 32
  • 55
Lim Yao
  • 3
  • 1
  • Can you share page URL? – Andersson Aug 02 '18 at 10:47
  • have a look here, it could be useful for u ;) https://stackoverflow.com/questions/21350605/python-selenium-click-on-button/37279279#37279279 – Carlo 1585 Aug 02 '18 at 10:48
  • page URL is like this (http://www.car.go.kr/jsp/report/fauRepInquiry_view.jsp) but this website is written by korean language. – Lim Yao Aug 02 '18 at 11:17
  • The locator you provided in your code isn't being found on the URL you provided. Please update your question with an example we can follow and an [mcve]. – JeffC Aug 02 '18 at 13:35

1 Answers1

0

You may try to Replace click event with action class,

from selenium.webdriver.common.action_chains import ActionChains

actions = ActionChains(driver)
actions.move_to_element("Your Element").click().perform()

If there is something which need to first hover, You can achieve with same class,

action.move_to_element("Your Element").build().perform()
Ishita Shah
  • 3,955
  • 2
  • 27
  • 51