2

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

Learning Curve
  • 1,449
  • 7
  • 30
  • 60
  • 1
    There is no class `rowhover` in the html you provided. There is `rowhover` as part of the `onmouseover` attribute. – Guy Oct 15 '18 at 11:03
  • For the first expression, try adding some wait and check the element is not in `` tag. – Guy Oct 15 '18 at 11:04
  • Upon inspecting the element, I can confirm there is no tag. Can't test with testing framework right now but will be able to confirm a bit later. – Learning Curve Oct 15 '18 at 11:17
  • @LearningCurve , try to remove `tbody` from XPath: `//*[@id="myList"]//tr` – Andersson Oct 15 '18 at 11:39
  • @Guy this table is in a modal window that opens in an iframe. Also, tried to get the xpath of the table but it returns null but when I xpath table row, it returns me the row. Any suggestion how I can resolve this situation. – Learning Curve Oct 15 '18 at 12:46
  • @LearningCurve You need to switch to the ` – Guy Oct 15 '18 at 12:52
  • @Guy Unfortunately, I can't past all of the html here. it is an old vb.net application where a model window is injected in an iframe. Let's say ifram name is 'myiFrame' and there are couple of nested div's (first level div id='div1', second level div id= 'div2') before that html table (id = 'table1'). Will you please advise how I can build the xpath for this sort of situation? – Learning Curve Oct 15 '18 at 13:02
  • @LearningCurve Start with switching to the ` – Guy Oct 15 '18 at 13:07

1 Answers1

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

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352