0

I have a problem when try to click for element using Selenium server method "click". The point is: sometimes some test failed, because one of element selenium doesnt fined, but in real - selenium clicked for element before the element is real displayed in page. Before the click i check isElementVisible & iselementPresent but it is doesnt help. Also i put Thread.sleep before all click.## Heading ## This is my peace of code for 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");
            }
        }

    }
2
  • So your problem is finding out how to accurately tell if this element is "ready" or not -> so clearly it is more than just "is it displayed"....does it move?
    – Arran
    Commented Oct 9, 2014 at 15:11
  • What do you mean when you say: ".does it move?" ?
    – igor
    Commented Oct 10, 2014 at 8:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.