application properties: retry.count = 5
One of the element locators is getting visible only during the 3rd or 4th retry, but if another element is also having the same issue within the given testcase, it never goes for 5 retries. Testcase fails after remaining retry left.
I have also noticed that the test case starts from the start after 5th retry and fails.
I have also referred the doc:
https://qmetry.github.io/qaf/latest/properties_list.html
retry.count property used by framework to determine number of retry of test case on failure not for element failure retry. For element failure retry you can impement web-element listener. Regarding element visibility you can try increasing wait time out using selenium.wait.timeout property
Related
In my Robot framework test case, I have following code snippet to load page and check whether page is successfully loading or not.
Go To ${href}
Wait For Condition return document.readyState=="complete" 5
Wait For Condition return document.visibilityState=="visible" 5
Wait Until Page Does Not Contain 404 page not found 5
But, in some cases, Go To ${href} takes around 3 min to load a page.
In Robot-framework, Is there any way to skip the page loading and retry if loading time is exceeded particular time?
There is keyword in the BuiltIn libarary called Wait Until Keyword Succeeds which can be used for retry.
You can give a 1 min timeout to your navigation keyword and run it a maximum 5 times with the afore mentioned keyword for example.
You can change the default timeout for the selenium framework with "Set Selenium Timeout" and then execute the "Go To ...", that will prevent you from waiting for 3 min
If you want to repeat the Go To until it doesn't fail you can use the "Wait Until Keyword Succeeds" as suggested in the other answer.
I am using Java and Selenium to write a test. Many times in my test i have to wait till the page or some part of it loads something. I want to wait till the load is finished. I found these two:
1) pageLoadTimeout
2) setScriptTimeout
But I don't know the exact difference between them or even if they are what I need.
The document says:
setScriptTimeout: Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error. If the timeout is negative, then the script will be allowed to run indefinitely.
and
pageLoadTimeout: Sets the amount of time to wait for a page load to complete before throwing an error. If the timeout is negative, page loads can be indefinite.
but I don't really get it.
what I need is a wait that stops the test till nothing is happening in the web page anymore.
Define "nothing is happening in the web page." Now define it in such a way that will satisfy every web page ever created, or that ever will be created. Did your definition include that no more network traffic is coming over the wire? Did your definition include that the onload event has fired? How about document.readyState returning a value meaning "complete?" Did you take JavaScript execution into account? How about JavaScript scheduled using window.setTimeout()? WebSockets? Service Workers? What about <frame> or <iframe> elements?
Now you know why WebDriver doesn't have a "wait for page complete" type of wait. The items mentioned above don't even begin to scratch the surface of the list of things a user could legitimately use in a definition of "nothing is happening on the page anymore." The correct approach would be to wait for the element you want to interact with on the next page to be available in the DOM. The WebDriverWait class is ideally suited for exactly this.
I'm have written a JUnit test case for logging into the application.
driver.findElement(By.linkText("SIGN IN")).click();
driver.findElement(By.id("uname")).sendKeys("user_sam");
driver.findElement(By.id("pas")).sendKeys("special26");
driver.findElement(By.id("loginb")).click();
My requirement is if Login is successful I can simply check whether a new element is being displayed or not which was not there before login and verify that successfully.
But if while entering the data some issue happened or the user is providing an invalid input at that time how to check till what line the execution has been done successfully.
You can log your statement and for more convenience you can also puts System.out.println(); on each steps . That will display the flow of your statement on console and logger will log them so you can refer it later on.
Refer below :-
http://toolsqa.com/selenium-webdriver/log4j-logging/
http://www.guru99.com/tutorial-on-log4j-and-logexpert-with-selenium.html
http://learn-automation.com/how-to-create-log-files-in-selenium/
Hope it will help you :)
I am interested in the default value of timeouts on selenium webdriver.
ImplicitlyWait, SetPageLoadTimeout and SetScriptTimeout.
Because I want to know, Do I need to set a values for those timeouts? or the default value is good for selenium webdriver working.
But I cannot find a correct answer, someone say the default value is 0, and other one say it is 30 sec.
These three timeouts are managed by the server-side of the Selenium equation. Your script, be it in Java, Python, Ruby, C#, or whatever, is a client that sends commands to a server that lives in the browser. (There may be an intermediary that relays commands to the browser, like Selenium grid. Unfortunately, it is also sometimes called a "server".)
The WebDriver specification, which was derived from Selenium has settled on the following values:
For implicit waits: 0 seconds. This means that if a selenium command does not find an element immediately, it reports immediately, rather than wait until an element is found.
For page loads: 300 seconds.
For script timeouts: 30 seconds.
(The specification gives the values in milliseconds. I've converted them to seconds for ease of reading.)
Selenium now follows the WebDriver specification.
In the past Selenium has used other values for these, however. For instance, the Firefox driver used to define its timeouts like this:
The implicit wait timeout is set to 0 by default. This means that if a command that finds elements does not find anything, it won't wait.
The page load timeout is set to -1 by default. This means that Selenium will wait indefinitely for the page to load.
What Saifur found is not the same as the page load timeout. That's a timeout between the Selenium client and the Selenium server, which is not particularly well explained on the page Saifur found.
The script timeout is set to 0 by default. A comment in the source code explains:
The amount of time, in milliseconds, this session should wait for asynchronous scripts to finish executing. If set to 0, then the timeout will not fire until the next event loop after the script is executed. This will give scripts that employ a 0-based setTimeout to finish.
So even if it set to zero, an asynchronous script can still execute but it has to complete before Selenium's timeout gets a chance to run again.
This is from the code that Selenium uses for Firefox. The other browsers use different code bases but they are supposed to behave consistently, at least with regards to things that are proper to Selenium itself, like these timeouts. So the values and their interpretations should be the same for other browsers too.
For implicit wait always default wait it ZERO. , you can check it here :
Selenium Webdriver diff. waits
And if you set custom time then web driver will wait to get element till that time and if element does not found till that time then only web driver will throw exception.
The Selenium documentation is very much unclear on these timeouts.
According to
this
the default timeout of the implicit-wait is 0
According to
this
any page that does not load in 60s will return http communication
timeout unless you explicitly overwrite the timeout.
Unfortunately, I did not find any reference to provide on
ScriptTimeout. But, it's defaults to 0 according to my knowledge
and experience. Will update you with any reference later
So I am in the process of writing some tests with Protractor for an angular application I am working on. I ran into an issue where a test was failing because I tried to click on an element that while existed, it could not be clicked because another element was above it and it was receiving the click event. The error was just that true not does equal false which gives no insight to the real underlaying issue. I have run into this issue many times with other tests so I knew pretty quickly was the issue was but if I had not experienced this before, I don't know how long it would take me to figure it out.
I am 99% sure that when you send a click event with the JSON Wire Protocol that if the element does receive the click, there will be a message relating to that in it's response. Is there any way with Protractor to get the JSON Wire Protocol responses on to the screen when running the tests or at least get the responses captured in a file or something?
Assuming you are using Jasmine (the default) i suggest you start using explicit waits for elements to be present and visible before interacting with them like in your example.
I'm using this custom mathers.
Then:
var theElementFinder = $('#someElm');
expect(theElementFinder).toBePresentAndDisplayed();
Regarding
a way with Protractor to get the JSON Wire Protocol responses
You already see selenium errors in your Terminal / Console output.