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.
Related
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.
I have written the Selenium webdriver java code to automate the test and its working fine. But I have lot of data input to test my web and it takes time. So when i minimize the IE to do some other task while it is running the automation, it is throwing error:
org.openqa.selenium.ElementNotVisibleException: Element is not displayed
Selenium WebDriver is trying to simulate "real" users interaction with the webpage. If a person can't click on a button not currently displayed, neither can Selenium.
ElementNotVisibleException occurs when the element you want to interact with is not displayed. When you minimize the browser some of the elements are no longer visible, even though they where in maximized window.
You can add scroll using moveToElement() from Actions class every time you want to perform any action (I don't recommend it, you increase significantly the chance for errors), or find another hardware solution, like plugging in another screen, run the test on another computer etc.
According to my experience, the Internet Explorer WebDriver is very oversensitive when it comes to disturbances from a real user while running test cases. It's better to not touch anything at all. ;-)
Try Chrome! This is much more robust and also faster.
Selenium script runs as a simulator. You cannot do another work when script is running. Chrome is fast but while running script in chrome you can not do other task like any other browser. If you minimize window, you will get exception "ElementNotVisible".
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.
Hi I am writing an SWTBot test which launches a file from a hyperlink using Program.launch. From the bot test I need to check that the 3rd party application opened to display the file. The only thing that seems obvious to me is checking that focus was lost on the underlying workbench but all focus, enabled and visible assertions remain true. Does anyone have any assertion ideas here?
I would recommend to avoid letting the test spawn a process at all. You'll have to wait for the process, kill that process in tear down to leave a clean environment, etc.
If possible I'd rather mock the program launching code during tests and verify that it gets executed if the hyperlink was selected.
But if you really want to test that the 3rd party app was launched , I would rather check if a new process was created. There seems to be neither support in the JRE nor a library to list OS processes so that you probably have to resort to System.exec() ps or tasklist.exe, depending on the OS you are running on.
"Debugception!"
You may notice that within the first 15 seconds of this YouTube video (from 1:01:01 to 1:01:16), Markus Persson (aka "Notch", creator of Minecraft) has somehow managed to save/update an application and attach a debugger to it while it was already under the process of being debugged, supposedly all with a simple keyboard shortcut. The previously coded application somehow magically became the newly edited one, and seemingly without relaunching it or spawning a new process... It's possible that this is just some form of locally remote debugging, but something about it just doesn't seem quite right.
I've spent several days Googling and asking around on how he was able to do this, yet to no avail. I've found no such option under Eclipse preferences, and whenever I try to save & debug an already running application, it simply launches a separate instance of the newly updated application, side-by-side with the older, outdated one.
Am I missing something? How was this possible?
How was he able to utilize such an astounding, powerful debugging feature?
Thanks in advance!
Update
Okay, so this appears to be a standard feature specific to Eclipse.
Coming from a background in NetBeans and Visual Studio, I'm astounded that this doesn't seem to exist elsewhere (or at least in NetBeans!)...
This is a built-in feature of Eclipse. If you edit a method while the program is running in debug mode, it will compile the new method, and replace the old method with the new version. If some thread was already running that method, it will jump back to the beginning (AFAIK; this might only happen when the program is paused).
You don't need to re-launch the program or set any special preferences. Just edit and save, and the magic will happen.
Eclipse can't always figure out how to merge your changes into the running program - usually if you changed anything outside a method body (including the method's parameters or return type). In this case, you will get a warning dialog, with the option to stop the program, restart the program or ignore the changes.