Hi!
i'll explain the flow a bit. this page where we call a iframe is
session controlled. so when the user initially visits the URL and he
is not logged in he is redirected to different application where he
logs in (OAuth) and is then redirected to the application under test's
home page; where post login we expect an iFrame with some controls. if
I enable java script for the HTML Unit driver it fails at a stage when
it is fetching this login page (the hostname changes to trunk-
nightly.us2.XXX.com).
org.openqa.selenium.WebDriverException:
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call
method "removeChild" of null (
http://trunk-nightly.us2.XXX.com/XX/js/
neo/core.js#22)
System info:
os.name: 'Windows 7', os.arch: 'amd64', os.version:
'6.1', java.version: '1.6.0_20'
Driver info: driver.version: htmlunit
at
org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:
280)
at
org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:
262)
at com.foo.bar.tests.TestUSSSanity.setup(TestUSSSanity.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod
$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
41)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
27)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
76)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:
46)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
197)
Caused by: com.gargoylesoftware.htmlunit.ScriptException: TypeError:
Cannot call method "removeChild" of null (
http://trunk-
nightly.us2.XXX.com/XX/js/neo/core.js#22)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
$HtmlUnitContextAction.run(JavaScriptEngine.java:527)
at
net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:
537)
at
net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:
538)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:
457)
at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:
910)
at
com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventListeners(EventListenersContainer.java:
159)
at
com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeListeners(EventListenersContainer.java:
273)
at
com.gargoylesoftware.htmlunit.javascript.host.Node.executeEvent(Node.java:
574)
at
com.gargoylesoftware.htmlunit.html.HtmlScript.setAndExecuteReadyState(HtmlScript.java:
470)
at
com.gargoylesoftware.htmlunit.html.HtmlPage.setReadyStateOnDeferredScriptsIfNeeded(HtmlPage.java:
1326)
at
com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:
203)
at
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:
427)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:
303)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:
360)
at
org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:
274)
... 25 more
Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError:
TypeError: Cannot call method "removeChild" of null (
http://trunk-
nightly.us2.XXX.com/XXX/js/neo/core.js#22)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:
3753)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:
3731)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:
3759)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:
3778)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:
3797)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:
2317)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:
2310)
at
net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:
1515)
at
net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:
845)
at
net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:
164)
at
net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:
429)
at
com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:
264)
at
net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:
3157)
at
net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:
162)
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:
485)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
$4.doRun(JavaScriptEngine.java:450)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
$HtmlUnitContextAction.run(JavaScriptEngine.java:521)
... 39 more
here's the setup method
@Before
public void setup() throws Exception {
webDriver = new HtmlUnitDriver(true);
webDriver.findElement(By.id("j_username")).sendKeys("
anadi...@foo.com");
WebElement password = webDriver.findElement(By.id("j_password"));
password.sendKeys("pass@word1");
password.submit();
selenium = new WebDriverBackedSelenium(webDriver,
webDriver.getCurrentUrl());
}
Disabling the java script I can correctly login through the
redirection and I also reach back to our app's home page. but I am not
able to switch to the iframe then.
I added this assertion after the login to confirm whether the iframe
is present or not:
Assert.assertTrue("Mobical Iframe is present",
selenium.isElementPresent("xpath=id('uss_iframe')"));
this call passes the assertion. and the switch fails
webDriver.switchTo().frame("uss_iframe");
webDriver.findElement(By.id("userservices"));
On Aug 31, 8:37 pm, "Eran M." <
eran....@gmail.com> wrote:
> Hi,
>
> The two things are not the same - since with Firefox, the Javascript is
> enabled as you load the page. With HtmlUnitDriver, you enable javascript
> *after* loading the page. Try using HtmlUnitDrivers's constructor that
> accepts a boolean to enable Javascript. Can you provide a dump of the DOM
> when you cannot find the element?
>
> Regards,
> Eran
>
> >
webdriver+...@googlegroups.com<
webdriver%2Bunsu...@googlegroups.com>
> > .