I have the following code in my test class (java) but the timeout doesn't seem to work (it has no effect at all). I've tested it with really slow connections and I expect it to fail after 5 secnods but it waits for page to load indefinately and sometimes it come back in 8-10 seconds and the test passes as the page has actually loaded but not within the time I specified. Any idea why page timeout command is not doing what it is supposed to do?
protected static WebDriver driver;
driver = new FirefoxDriver();
driver.manage().timeouts().pageLoadTimeout(5,TimeUnit.SECONDS);
driver.get("http://www.google.com");
I'm using Selenium 2.20.0.
Thanks in advance
Then report it as an issue
http://code.google.com/p/selenium/issues/list
pageLoadTimeOut makes no sense without "unstable" Firefox profile.
Probably, you will have to either download the plugin been mentioned at the selenium download page OR write a while loop that would run indefinitely and break only when the element is found. Make use of try-catch blocks as well.
Related
I tried to write an test application to capture the text from stdout of an 3rd console application.
I studied from many articles to use the CreatePipe API and have INDEED obtained the text AFTER the console application HAD FINISHED running.
I tried to make the console application keep printing something for more than 60 seconds, and the ReadFile funcion didn't return during this 60 seconds at all.
For the same purpose, I tried popen and fread, and everything went fine except the black console window created by popen.
Although the ReadFileEx and something about the overlapped I/O seems to be able to solve this problem but it's actually not.
Because the ReadFileEx required the file handle to be created to support overlapping, and this is always impossilbe because the file handle is created by the 3rd console application. It won't be under control unless we develop the console application by ourselves.
So is there any way to capture stdout from a 3rd console application whose life cycle is very long by CreatePipe?
Thanks in advance!
I finaly figured out the problem is the 3rd console application "MAC.EXE" doesn't invoke "fflush" after each progress output....
I manually append the fflush operation in the source code of mac.exe and the problem gets resolved.
So a new question is:
If the child process never call fflush and seldom print during running, how to read the content correctly?
So, I had a working xamarin forms app that used azure mobile services. I upgraded the server side to use mobile app service and upgraded the nugets in my client to use the latest and greatest client codes.
I manually updated my test/ios simulator sqlite db to use the proper column names for the system properties since they dropped the double underscore prefix.
When I finally got it all built and tried to run in the ios 6/8.3 simulator it ran fine until it hit the InitializeAsync method. It doesn't throw (its in a try catch) and I let it run for a long time and it just sits there.
I then tried to change the db name so it would make it from scratch, which it did but still just hung. So I then tried to simplify it to a single table and took out my delegating handler so it was as basic as I could get it and it still just hangs.
Has anyone else had this problem? I am at a complete loss because I don't get an error. Not sure where to start.
Thanks.
Edit, code added:
var store = new MobileServiceSQLiteStore(_localDatabaseName);
store.DefineTable<Profile>();
try
{
await _mobileService.SyncContext.InitializeAsync(store);
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
I also tried with ConfigureAwait(false) as suggested but it made no difference.
I set breakpoints in the catch and the code that immediately follows this block but they are never hit.
Ok, so I poked around a bit more and found some info on deadlocked threads answered by Stephen Cleary, the guru of async/await.
It turned me onto looking upstream. The call into my azure init code looked like this:
var azureService = Container.Get<IAzureService>();
azureService.InitializeAzync().Wait();
Which was in the constructor of the calling component.
So, I changed it to this:
try
{
Task.Run(() => azureService.InitializeAsync()).Wait();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
And the SyncContext.InitializeAsync() call worked fine and continued on.
So, I don't really know the answer for this, I guess the internals of the new azure client do something differently than the old code since using Wait() was how I did it before and never had a problem. But there was some sort of threading deadlock. Very odd and took days to get past, now I have to fix the next deadlock I hit. If Stephen is out there and can offer some clarification that would be great.
Had this same issue - changing to a Task.Run and ConfigureAwait(false) did fix it.
Very odd thing is the same code worked fine with Mobile Services, but broke when we upgraded to Mobile App Services.
I have a Loadrunner Test Scenario, here is the snapshot for it:
after opening my Test Scenario with Loadrunner Controller, I click then the "Start Scenario" button, the Scenario must run for 2 Hours, but it stops after 1 minute, and get the following Error:
Failed to stop Service Virtualization.
Failed to start Service Virtualization.
here you can see the error snapshot:
to increase the size of the snapshot please: Ctrl++
It seems that you have unwittingly activated an integration with HP Service Virtualization (or SV for short), without having SV installed on the same machine. In order to remove it, open the SV configuration dialog and uncheck all the entries.
I solved the problem with a lot of effort.
the problem is, when you have test scenario, which worked before, and you try to remove some script (groups) of the scenario,after that the test scenario will not work, what I've done, is I created from scratch a new scenario with the same test scripts, and voila it worked, I hope everyone will pay attention at that in the future
I have a requirement to open 50 to 100 URLs once and verify the login for each URL. All URLs belongs to Same App but hosted for different customers? How I can open multiple browsers, say 20 to 50 browser with different URLs using Selenium WebDriver? I tried TestNG with Parallel attribute set to "Tests" and instantiating driver object in #BeforeTest but after opening 2 browsers getting selenium exception as browser closed or died for 3rd browser.
Below find code for this.
#Test
#Parameters({ "url" })
public void testParallel(String url) throws Exception {
try {
driver.get(url);
int i = 0;
i++;
System.out.println("Browser Count" + i);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I think it is not possible to use multiple IEDriver instances in parallel on the same machine using Java bindings. (remember reading somewhere.. .NET bindings support parallel IE instances)
As per official documentation of IEDriver, "Unlike other WebDriver classes, there should only ever be a single InternetExplorerDriver instance at one time for some language bindings. If you need to run more than one instance of the InternetExplorerDriver at a time, consider using the RemoteWebDriver and virtual machines.". Refer here.
This should work with FirefoxDriver provided you have got your testng xml right. Or if you want it on IE, then you should consider setting up a grid and launch IE nodes on different machines, so that parallel runs can happen.
Why do you need to open them all at once? Selenium is not designed for load testing. If you want to check how your application or server is doing under load you better have a look at JMeter.
For a test like that I would recommend not using a browser per-se but instead use HTMLUnit driver (which is like a headless browser). Also, there is a thing called GhostDriver than might also accomplish similar. Still, you should probably use a remote Grid node+hub but you don't need to in order to accomplish your goal.
Selenium can do load testing in that respect. Also, I wouldh't use TestNG: instead, I would use Gradle or Maven because they have JUnit forking-multithread capability in themselves. In Gradle or Maven, create a task that filters and identifies certain test class and then forks processes to run them multi-threaded. I created an example here.
Does webdriver maintain unique browser sessions by default when used with multiple threads i.e multiple tests in parallel? If not then how do I make it maintain unique sessions?
By
Using TestNG , we can open multiple browser session (firefox) and run tests.
I am closer to "no" - If I run my tests in Selenium Grid and some browser window "dies" (hangs up unexpectedly, because I am bad programmer), restarting the tests cause my webapp to tell me "another user with same user name is already logged in"
But in normal Selenium Webdriver, calling driver = new FirefoxDriver(); caused new session. Always.
You can use Grid configuration; It is exactly what you need.See here an example of parallel test run.
Grid can support multiple sessions. You can configure this when you register your node to the hub, using parameters : -maxSession x -browser browserName=firefox,maxInstances=x, where x represents desired number of sessions.