【问题标题】:webdrivr click the button which will call Javascript can't workwebdrivr 单击将调用 Javascript 的按钮不起作用
【发布时间】:2014-08-25 12:03:49
【问题描述】:

(1) html:

<table class="title_button" onclick="onSave();" onmouseout="this.className='title_button'; save_moveout();" onmouseover="this.className='title_button_hi'; save_movein();" title="Copy Running-config to Startup-config">
    <tbody>
        <tr>
            <td>
                <img id="title_btn_save" src="https://192.168.100.116/image/title_btn_alert.gif">
            </td>
            <td id="title_save">Save</td>
        </tr>
    </tbody>
</table>

(2) Webdriver Java:

这两种方法都试过了,都不行。

driver.findElement(By.id("title_save")).click();
driver.findElement(By.xpath("/html/body/div/table/tbody/tr/td/table/tbody/tr/td[8]/table/tbody/tr/td/div/table/tbody/tr/td[2][@id='title_save'")).click();

(3) 例外:

webdriver element is not currently interactable and may not be manipulated.

【问题讨论】:

    标签: java javascript selenium selenium-webdriver webdriver


    【解决方案1】:

    您正试图点击td 元素,但这里实际的“可点击”元素是table

    driver.findElement(By.className("title_button")).click();
    

    【讨论】:

      【解决方案2】:

      您尝试单击的元素似乎已禁用,并且无法对该元素执行单击操作。

      尝试在另一个元素上执行点击操作,例如上:

      driver.findElement(By.css(".title_button tr")).click();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-03-25
        • 1970-01-01
        • 2023-04-05
        • 2015-02-06
        • 1970-01-01
        相关资源
        最近更新 更多