有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Selenium服务器,在ASP中单击定位器。NET网页工作不稳定

我在尝试使用Selenium服务器方法“click”单击元素时遇到问题。 重点是: 有时一些测试失败了,因为元素selenium中的一个元素没有被定义,但在real中,selenium在元素真正显示在页面之前单击了元素。在单击之前,我检查isElementVisible&;我在场,但没有帮助。我还放了线。在所有点击之前睡觉。##标题## 这是我为WaitAndClick编写的代码

public void waitAndClick(String locator) throws Exception {
        long ts = System.currentTimeMillis();
        for (int second = 0;; second++) {
            if (selenium.isElementPresent(locator) == true && selenium.isVisible(locator) == true) {
            //System.out.println("click true");
                Thread.sleep(250);

                selenium.click(locator);
                 //selenium.fireEvent(locator,"click");
            //selenium.fireEvent(locator, "click");
                break;
            } else {
                //System.out.println("click false");
                Thread.sleep(100);

            }
            if (System.currentTimeMillis() - ts > 20000) {
                throw new Exception("WaitAndClick for " + locator + " out off 20 seconds");
            }
        }

    }

共 (0) 个答案