How to click a row that has javascript on click event in RIDE

▼魔方 西西 提交于 2020-01-15 04:14:27

问题


I am trying to click a row that has a javascript onclick function in RIDE IDE by using Robot Frame Work with Selenium2 library.

<tr class="lstrow" onclick="javascript:selectItem(this);" onmouseover="javascript:this.className='rowhover';" onmouseout="javascript:this.className='row';">

When i perform click event at following xpath, it says element at path not found.

//*[@id="myList"]/tbody/tr[0]

By inspecting the element, I can confirm this row is there. Also tried to pin point the 'rowhover' class at this xpath but still not successful. Not even sure if I really can select a specific class at a specific xpath.

//*[@id="myList"]/tbody/tr[0][contains(@class,'rowhover')] //Not sure if it is right


回答1:


The desired element is a JavaScript enabled element so you need to induce wait and you can use either/both (clubbing up) of the following solutions:

  • Python Solution

    • Wait Until Element Is Visible:

      Wait Until Element Is Visible    xpath=//tr[@class="lstrow"]    20  seconds
      Set Focus To Element    xpath=//tr[@class="lstrow"]
      # invoke click
      
    • Wait Until Element Is Enabled:

      Wait Until Element Is Enabled    xpath=//tr[@class="lstrow"]    20  seconds
      Set Focus To Element    xpath=//tr[@class="lstrow"]
      # invoke click
      
  • You can find a detailed discussion about Wait Until Element Is Visible and Wait Until Element Is Enabled in Robotframework: Selenium2Lib: Wait Until (…) Keywords

  • Reference: Selenium2Library



来源:https://stackoverflow.com/questions/52815184/how-to-click-a-row-that-has-javascript-on-click-event-in-ride

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!