Selenium-RC doesn't recognize waitForPageToLoad under googlechrome

125 views
Skip to first unread message

Mellow Crow

unread,
Nov 21, 2011, 12:28:56 AM11/21/11
to Selenium Users
My selenium tests are failing for Google Chome because, it seems,
Selenium-RC doesn't recognize waitForPageToLoad when running against
the googlechrome driver.

I'm running Selenium-RC under Selenium Grid but it seems like an issue
directly related to Selenium-RC.


MY PLATFOM:

Win XP Pro SP3
Selenium Grid 1.0.8, with components updated as follows:
* Selenium-RC: C:\Program Files\selenium-grid-1.0.8\vendor\selenium-
server-standalone-2.12.0.jar
* Selenium-RC Java Client: C:\Program Files\selenium-grid-1.0.8\vendor
\selenium-java-2.12.0.jar
* TestNG: C:\Program Files\selenium-grid-1.0.8\vendor\testng-6.3.jar
Google Chrome Version: 15


MY CODE (for context):

I create a TestNG Suite and Test(s) programmatically (rather than via
direct XML).

I launch Grid and an Selenium-RC instance for a browser with windows
batch command. E.g.

<code>
start cmd /k ant launch-hub
start cmd /k ant -Dhost=sand -Dport=5557 -Denvironment="*googlechrome"
-DseleniumArgs="-trustAllSSLcertificates -disable-web-security -
browserSideLog -log selenium.log" launch-remote-control
</code>


I have a custom base class which TestNG hooks into, the start up code
is:

<code>
public static Selenium selenium;

@BeforeMethod(groups = {"default", "example", "short"}, alwaysRun
= true)
@Parameters({"seleniumHost", "seleniumPort", "browser", "website",
"subfolder"})
protected void startSession(String seleniumHost, int seleniumPort,
String browser, String website, String subfolder) {

// Running google chrome requires this.
HttpCommandProcessor proc = new
HttpCommandProcessor(seleniumHost, seleniumPort, browser, website);
selenium = new DefaultSelenium(proc);
BrowserConfigurationOptions bco = new BrowserConfigurationOptions();
selenium.start(bco.setCommandLineFlags("--disable-web-security"));

selenium.setTimeout(Timeout);


// Open web page under test to cover the last 2/3rds of the
screen.
// Works regardless of your resolution.
// moveTo(x, y); resizeTo(x, y);
selenium.getEval("window.moveTo(screen.availWidth / 3,0);
window.resizeTo(screen.availWidth * (2/3), screen.availHeight); ");
selenium.open(subfolder); // E.g. "/give/"
}
</code>

In the actual tests of my web form the relevant code is

<code>
public void myTest(int indentLevel) throws Throwable {
...
selenium.click("cmdSubmit");
selenium.waitForPageToLoad(Timeout);
assertTrue(selenium.isTextPresent("Some Text That is Present On the
Next Page"));
...
}
</code>


WHAT I EXPECT

The test not to fail. The texts pass fine in Firefox and IE7.


WHAT I GET

Output that expresses my assertion failed

<output>
FAILED: generalMatrix
java.lang.AssertionError: expected:<true> but was:<false>
at org.testng.Assert.fail(Assert.java:89)
at org.testng.Assert.failNotEquals(Assert.java:480)
at org.testng.Assert.assertTrue(Assert.java:37)
at org.testng.Assert.assertTrue(Assert.java:47)
at au.org.thpa.giveform.GiveTestBase$TestPart.eway(GiveTestBase.java:
374)
at au.org.thpa.giveform.BasicTests.generalMatrix(BasicTests.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:
76)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:673)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
at
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:
125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:
109)
at org.testng.TestRunner.runWorkers(TestRunner.java:1147)
at org.testng.TestRunner.privateRun(TestRunner.java:749)
at org.testng.TestRunner.run(TestRunner.java:600)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274)
at org.testng.SuiteRunner.run(SuiteRunner.java:223)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1039)
at org.testng.TestNG.runSuitesLocally(TestNG.java:964)
at org.testng.TestNG.run(TestNG.java:900)
at
au.com.softmake.testbase.TestNGAndSeleniumWrapper.Run(TestNGAndSeleniumWrapper.java:
119)
at au.com.softmake.testbase.Start.main(Start.java:28)
</output>


HYPOTHESIS

The hypothesis: The waitForPageToLoad doesn't get recognized by the
Selenium-RC/googlechrome combination. Code execution runs my
assertion before the browser has had a chance to load the new page
and so selenium.isTextPresent("Some Text That is Present") returns
false.

HELP?

Can anybody else get waitForPageToLoad to work with Selenium-RC/
googlechrome? Any other suggestions?

Krishnan Mahadevan

unread,
Nov 21, 2011, 1:18:32 AM11/21/11
to seleniu...@googlegroups.com
Why would you want to couple Grid 1.0.8 with Selenium 2.12.0 jar ? When selenium 2.12.0 already has the Grid embedded within ?

Can you please retry getting rid of Grid 1.0.8 and instead using Selenium 2.12.0 in the Grid mode ?

You can read more about how to use selenium 2.12.0 as Grid here : http://code.google.com/p/selenium/wiki/Grid2


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Mellow Crow

unread,
Dec 5, 2011, 7:50:03 AM12/5/11
to Selenium Users
Thanks Krishnan, that was a very helpful tip.

I followed your suggestion and it certainly feels better to get rid of
some baggage from Grid 1.0.8 like ant.

However, I'm encountering problems running my Selenium 1/RC code with
custom configurations.

E.g with

- name: 'Firefox 3.6'
browser: 'firefox C:\Program Files\Mozilla Firefox
3\firefox.exe'

in my .yml

So it takes me a step back. Maybe I'll be forced to dive fully in and
start using the webdriver API, but I am reluctant to migrate given the
time I spent learning all the tips and tricks needed to get selenium 1
running.

Furthermore, given the warning at
http://seleniumhq.org/docs/appendix_migrating_from_rc_to_webdriver.html#waitforpagetoload-returns-too-soon,
"WaitForPageToLoad Returns Too Soon", my original problem might not be
solved even if I go all the way (to using Grid 2, Selenium 2, and
Webdriver).

On Nov 21, 5:18 pm, Krishnan Mahadevan

Mellow Crow

unread,
Dec 9, 2011, 4:47:46 AM12/9/11
to Selenium Users
For others that may come across these posts in the future:

After migrating to Grid2 (using selenium-server-standalone-2.14.0.jar)
I encountered the same WaitForPageToLoad problems under Google Chrome.
Additionally, as mentioned above, Grid2 doesn't recognize custom paths/
browser environments using the Grid1 .yml configuration format (it
does support Grid1 .yml but not for custom paths/browser
environments).

So I've gone back to using Grid1 (1.0.8) but with an updated selenium-
server (selenium-server-standalone-2.14.0.jar) and selenium server
java client (selenium-java-2.14.0.jar).

Reply all
Reply to author
Forward
0 new messages