本文介绍了如何在RIDE中单击具有javascript on click事件的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过使用带有Selenium2库的Robot Frame Work在RIDE IDE中单击具有javascript onclick函数的行.

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';">

当我在以下xpath处执行click事件时,它表示未找到路径中的元素.

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

通过检查元素,我可以确认这一行在那儿.还尝试将"rowhover"类指向此xpath,但仍未成功.甚至不确定我是否真的可以在特定的xpath中选择特定的类.

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.

推荐答案

所需的元素是 JavaScript 已启用的元素,因此您需要引发 wait ,并且可以使用以下两种解决方案之一/两者都可以:

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解决方案

  • 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
    

  • 您可以在

    参考: Selenium2Library

    这篇关于如何在RIDE中单击具有javascript on click事件的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    10-30 01:21