how do i work around 429 errors in selenium? - java

I run into 429 errors a lot in selenium, because the driver is too fast for the server. this causes the website to get stuck (with no error message presented to the user). I use waits and I've tried using the sleep method but it doesn't always work. Is there anything I can do or is this a design flaw on the website - shouldn't the error be presented to the user so I can try to reload the page?
I am using incognito mode so cookies aren't an issue.

try adding the bellow line of code after declaring the driver
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
also using sleep having assigned it a fair amount of time? make sure that it's using millescondes
thread.sleep(3000);

It might be an issue that has to be handled in the source code of the application. I would do the following:
Run a performance test and see if I can replicate it.
Check the logs of the application to see if this happening frequently on production.
Please see following article for dev to handle 429 errors --> link
Otherwise the solution provided by #hamza belatra should be sufficient.
Unless it is a problem in your Test Architecture code, how to the driver is handled and so on.

Related

How to simulate specific code part as if previous ones were executed

I'm writing automation code by using selenium web driver in eclipse. as per my assumption, whole case execution time probably will take about five minutes but once my code got an error, I have to run it from the beginning after changing the code to see whether changing part is working fine or not. Is there a way to simulate the part being until to fixed code?
Simulate the error outside of the test script, fix it, put it inside the test and run it.
OR comment the code in a manner that the line where the error is happening still works.
For these 2 solutions, you need to know:
What the error is
What the application does
Does this part of the script work without some other parts?
Can i manually do the necessary steps for the test on the browser with debugging, so it's quicker to reach the desired step?
You just need to improvise.
Hope this helps.
There is no way for you to accomplish this, unless of course you code the scenario in such a way that you're able to mimic that state that the application WOULD be in had you ran through the entire test. There's no magical way to make it happen by itself.

Chrome stucks after 30 or 40 minutes of work

In my tests chrome stucks after 30 or 40 minutes of work with error:
[710.758][SEVERE]: Unable to receive message from renderer
My current functionally is to take some txt data from web page and add it to inputs using executeScript. Can someone to help with this issue? Or just tell me correct way to resolve this problem
As far as I can remember, Chrome uses its own task manager... it can be opened by pressing shift+esc, assuming you don't have another program hooking that hotkey pair. Open the task manager and monitor the different tasks to see which one is bogging.
(couldn't leave a comment with low rep)
In my experience, this kind of error happens when you have something on the browser side which is preventing the part of Selenium that lives in the browser from doing its work. Whenever I've seen it, it was because some code went into an infinite loop. This would prevent the JavaScript engine from giving control to anything else and would prevent Selenium from being able to poll the renderer.
Besides the message Unable to receive message from renderer the other symptom would be a relatively high CPU usage from the test browser. Linux was pretty good about preventing the runaway browser from completely hosing my machine. I had to take a look specifically at the browser's processes to see the problem.

Does execution of a Java code written to test a webpage using webdriver depends on system?

Actually the question sounds very stupid but I was force to ask this because from yesterday i am trying to test some google web pages but the codes written in Java were stop responding at some certain point. Some time I receive Exception and some time some time getting no result(also don't get any compilation error or any Exception).
My main concern for asking the question is that the same code(without making any change by members) which is not running on my system is running fine on other statckoverflow members systems.
I am posting the links of those two tests which are not executing on my system but others are executing it. See the links here 1st Link and 2nd Link
No it not depends on your system but yes it depends on the jdk which is installed on your system. After doing a lot of research for my question i came to know that the webdriver code written in java does't not respond or run according to the system specification but it runs according to the web browser which you are using (firefox, chrom or ie)

Selenium RC and Internet Explorer

I am trying to create a fully-automated test suite for a web application, using Selenium RC and test cases written in Java. However, I have encountered a few problems that I have not been able to solve. Please let me know if you have a suggestion about any of these issues.
Single window mode. I would like to run single window mode because I think it will provide a significant performance improvement, and probably solve problem 2. I am able to run my test cases in single window mode with Firefox and everything works as expected, with much faster execution. However, I have not been able to get my test cases to execute when using single window mode with Internet Explorer; button clicks do not work at all, so the tests fail due to the browser never advancing to the next screen. The exact same test case executes fine in multi-window Internet Explorer. Is there some kind of trick I can use to get this working?
When running in multi-window mode, if there is an error in the test, or if the user exits the Selenium GUI window, the browser never closes. I know that it is possible to get the process id and kill it, but this seems rather dangerous, especially if the user is running multiple instances of the browser. This is part of the reason that I would like to use single window mode, if possible. Is there some other way, possibly by handling the window close event for the Selenium GUI, to solve this?
I am unable to use the waitForPageToLoad command in any of my test scripts because it will never recognize that the page has loaded and resume execution. I think this is because the pages use Javascript, but I am not sure; I don't have too much experience in webpage development. Right now, I am using the wait command and specifying the amount of time to wait. However, this is very unreliable, sometimes if the Internet connection is slow, my tests fail because the wait times are not long enough. Other times the tests are excessively slow, due to long wait times. Any ideas for how to handle this problem?
Thank you! I appreciate any answers or suggestions you can give. Please let me know if you would like some more information.
For multi widow close issue, you need to handle the exceptions. Call the close function in the finally block will resolve the window close issue.
For Page refresh, you need to check that manually and call in correct places. Usually clicking on links will cause page refresh before showing next screen.
Have you tried IE HTA mode? When I used to mess with this stuff it was the only reliable way to run tests on IE.
Not sure
You need to use the wait class. In essence you make an action then poll on an element which isn't present yet but you know will be when its safe to continue with the test. So you only ever wait the minimum time needed.

SeleniumException: ERROR: There was an unexpected Alert!

I get this error while running selenium RC tests against IE7.
com.thoughtworks.selenium.SeleniumException: ERROR: There was an unexpected Alert! [error:[object Error]]
It happens whenever I attempt to click a link or a tab or anything clickable. Any Ideas guys. This is really frustrating.
Checking the Google search results for your error message, and the selenium development mailing list, it sounds as if this is not a bug in Selenium but rather it is Selenium telling you that an unexpected window.alert() function was called in your web application, and that Selenium does not know how to handle it because you did not tell it how to.
I'd be surprised if the same issue isn't occurring in other browsers. Perhaps your application behaves differently depending on the browser? Basically Selenium is reporting that it can't move onto further commands after you are clicking on these links or tabs because it has detected an unexpected JavaScript alert. You wont see these alerts because Selenium consumes them. There are a few things you can do to work out what's going on.
The first thing I'd suggest is to just check your application in IE7. Manually complete the steps of your tests - do you see the JavaScript alerts? If so, you will need to add the appropriate commands to your Selenium test.
If for some reason you can't replicate the alerts manually you can either dismiss the alert by using the the getAlert command, or use the response from getAlert to find out the text of the unexpected alert.
Java/TestNG example for finding out the message of the alert:
assertEquals(selenium.getAlert(), "Hello World");
The above will still cause your test to fail (unless the alert really does say 'Hello World'), but will fail with a message similar to "expected 'Hello World' but was 'Your unexpected alert message'".
I'm getting a similar thing.
No error in IE, JS error popup in Chrome, nothing in FF...until I run my Selenium script and it reports an unexpected error.
Amusingly when I do selenium.IsAlertPresent() it returns false, even though it says there was one.
I'm seeing the same error. Normally we run our test using C#, but in this case we are setting up some simple tests using the Selenium IDE.
Since Selenium IDE records your events and then allows you to play them back you would expect it to handle the alert. When looking at the events it records it appears it's capturing the alert. However, when you play it back the events are out of order.
First it captures the click event. Then is uses assertAlert to make sure the alert happened.
The problem occurs when you play it back. It does the click event and then errors out. If you move the assertAlert statement before the click event it doesn't work. If you change the assertAlert to waitForAlert that doesn't work either. I can't seem to figure out anyway to get the playback working in the Selenium IDE. If I didn't need this runnable for a non-techy I'd just put it into my regular tests and be done with it.
Edit: After further review it appears the alert message isn't matching. Even though it grabbed the alert itself when doing the record. Visual inspection doesn't do anything to help me determine what it considers different.
I've seen this error also. In my case the issue was the latency in an Ajax response object was causing Selenium IDE error. The solution that worked for me was to add a pause command right after any Ajax calls in the test script.
The call below was taking few seconds to return with valid Ajax response
click
css=#form3 > div.addButton > button.btn.btn-primary
By adding a pause clause, the "Unexpected alert" issue was resolved
pause
5000
I Suggest you to test manually those steps which are there in your selenium test.If it is not reproducible then it might not be the problem in the page.
please debug your selenium script with assert function for identifying where is it finding the unexpected alert.
if (selenium.isAlertPresent()) {
assertEquals(selenium.getAlert(), "Hello World");
}
which will help you identify the problem. I suggest you to repeat the test because you may find that assertion occurring in different part of your code.

Categories

Resources