Is proxy injection mode supposed to work at all or not ?
The following code, which (not surprisingly) works OK in the default mode
browser.open("http://www.ca.com");
browser.waitForPageToLoad("50000");
fails with the following exception in proxy injection mode
org.openqa.selenium.server.RemoteCommandException: timed out waiting for window '' to appear
Any ideas ?
How do you set-up the proxy ?
did you try do ping it to see the latency ?
can you provide the code you use to set-up the selenium-server ?
You don't have to "setup" any proxy in proxy injection mode, you just run Selenium with -proxyInjectionMode parameter.
See the following bug for more details - http://jira.openqa.org/browse/SRC-678
yep - you right - I confused it with setting a custom proxy .
but nevertheless - I've tested your case ( selenium 1.0 , started with -proxyInjectionMode ).
the test was
browser = new DefaultSelenium( "localhost", 4444, "*firefox", "http://localhost/" );
browser.start();
browser.open( url );
// some test .........
browser.close;
it worked fine ( I also tested it with ebay according the url to the bug you've sent ).
Can you send me how do you initialize the browser ?
Which version of browser/selenium are you using ?
Did you use waitForPageToLoad ?
The problem is that waitForPageToLoad times out.
All the details and code are in the bug report.
Yep - you're right . the problem is in waitForPageToLoad.
I''ve added stackTrace from selenium-server to your bug ( http://jira.openqa.org/browse/SRC-678 )
this happens in Selenium-Server ( the stack trace you placed in the bug is from selenium browser ) , and the problem is ( I think ) in fact that proxyInjectionMode inserts another Frame to the page - and the waitForLoad() method confuses it with the actual page.
In general from what I've found in the net - using waitForPageToLoad is not always encouraged , probably because of these non deterministic behaviours.
I've debugged the server - in proxyInjectionMode it has a frame named "top" - which causes the wait to fail.
What's the alterantive to waitForPageToLoad ?
think you can use browser.wait() ,
or even Thread.sleep() -> cause the page loading is being performed in separate Thread anyway.
browser.wait(); fails with Firefoxjava.lang.IllegalMonitorStateException exception.
Any more suggestions ?
Thanks.
any Object.wait() can throw that exception ( in addition to InterrupedException ) . refer to http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#wait(long)
if you use Thread.sleep() InterruptedException should also be caught ( http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#sleep(long) )
so in general - simply surround it with try-catch . this will do the work
Hmm...well... I was under impression that its kinda trivial that the problem is not the fact that the exception is not cought, but the fact that it is generated in the first place.
Well - I simply thought that it's trivial to read the following : http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait(long)
The exception is generated because you don't own the monitor on selenium.
in case you use browser.wait(); you probably forgot to synchronize it
synchronized(browser)
{
browser.wait(SOME_TIMEOUT);
browser.notifyAll();
}
or you can use Thread.sleep() -> as it embeds the synchronized block - and you need to catch only InterruptedException.
Hmm... oops. And thanks for the JAva lesson about synchronization.
At any rate, the code you suggested does not work - it waits for the specified amout of time even after the page is loaded. BTW InterruptedException is not generated, but this is not the problem - I still did not find a substitute for waitForPageToLoad
Is it necessary to use waitForPageToLoad at all ?
welcome . ( didn't mean to give you a lesson - just wanted to ensure you RTFM
).
The code I've suggested - simply waits the specified amount of time ( InterruptedException will be generated if some other thread Interrups the selenium during the wait ).
The waitForPageToLoad() - is special cause it stops waiting when the page is loaded ( you've opened a bug in it no ? ).
you can replace it with wait() only if you know when exactly the page is fully loaded - i.e. you know of any element which loads in the end.
Let's say you have element with id = "someLastElement1" - they you can use the following code ( which emulates the waitForPageToLoad() pretty well ).
private void customWaitForPageToLoad(long timeout, long singleStep )
{
long maxWait = 0;
while( maxWait < timeout )
{
if( browser.isElementPresent( "someLastElement1" ) )
{
return;
}
else
{
maxWait += singleStep;
try
{
Thread.sleep( singleStep );
}
catch ( InterruptedException e )
{
e.printStackTrace();
// your interrupt handling
}
}
}
}
the singleStep should be ~100milliseconds - this way you won't wait too much after page loaded.
