0

I have a webelement as follows on which i need to perform click method:

<a class="pull-right add_card" href="javascript:void(0);" onclick="showHideCardField(this);deselect(this)">+ Add New Card</a>

If I use selenium2library methods as follows:

Click Element  xpath=.//*[@class='pull-right add_card']

it does not work and throws following error:

InvalidElementStateException: Message: invalid element state: Element is not currently interactable and may not be manipulated

I tried to execute javacsript on same as follows:

Execute JavaScript    document.getElementsByClassName("pull-right add_card")[0].onclick()

but it also throws an error as follows:

WebDriverException: Message: unknown error: showHideCardField is not defined

This issue is not related to an element not traceable but to the javascript element not clickable. Please help on how to fix the issue. I need to click on this element.

S.C
  • 61
  • 4
  • 15
  • where have you defined `showHideCardField()` ? – Muhammad Usman Apr 11 '18 at 07:46
  • 1
    Possible duplicate of [How to resolve ElementNotInteractableException in Selenium webdriver?](https://stackoverflow.com/questions/43868009/how-to-resolve-elementnotinteractableexception-in-selenium-webdriver) – undetected Selenium Apr 11 '18 at 07:46
  • @GeorgeBailey, I have not defined showHideCardField method, this is actually web element's onclick method and is part of application code. – S.C Apr 11 '18 at 07:55

1 Answers1

0

You could try like below in robot framework.

${hidden_objs}=  Execute Javascript
...  return document.getElementsByClassName('pull-right add_card')
${select_obj}=   Set Variable    ${hidden_objs[0]}
Wait until keyword succeeds    10s    5s        Set Focus To Element    ${select_obj}
Wait until keyword succeeds    20s    5s        Click Element     ${select_obj}
bsd007
  • 348
  • 2
  • 8