I am using Selenium with Web Driver.
I have a form to be filled up in a Light Box. Now when I click “submit”. That Light Box gets closed and an easy notification gets generated on top of the page which gets disappeared after a couple of sec.
Now my question is: When I do
driver.findElement(By.xpath(".//*[@id='createCaseBtn']")).click(); // x-path of submit button
How shall I check whether that notification message appeared on the UI.
Because when I do
driver.findElement(By.xpath(".//*[@id='easyNotification']")).getText(); // x-path of easyNotification message
I shows me that it is Unable to locate the element which seems logically correct because at that time the notification message is not present on the UI. It is only after completion of AJAX Request (for submition of form) that message gets appeared on the UI.
Please help!!!!
Thanks
Have used Explicit Waits. It worked fine for me:
An explicit waits is code you define to wait for a certain condition to occur before proceeding further in the code. The worst case of this is Thread.sleep(), which sets the condition to an exact time period to wait. There are some convenience methods provided that help you write code that will wait only as long as required. WebDriverWait in combination with ExpectedCondition is one way this can be accomplished.