jBrowserDriver
jBrowserDriver copied to clipboard
Support third-party WebElements which implement HasIdentity
Hi,
While highlighting an element am getting the following exception could you please look into it. Using the following code for highlighting. Let me know if you need more info.
private static void transform(WebElement element, String color, int i) {
executeJavaScript(
"arguments[0].setAttribute('__selenideHighlighting', 'done'); "
+ "arguments[0].setAttribute(arguments[1], arguments[2])",
element, "style", "border: " + i + "px solid " + color
+ "; border-style: dotted; " + "transform: scale(1, 1."
+ i + ");");
}
org.openqa.selenium.WebDriverException: Remote browser exception.
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'KMI-DS023474E', ip: '193.225.171.90', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: driver.version: JBrowserDriver
at com.machinepublishers.jbrowserdriver.Util.handleException(Util.java:126)
at com.machinepublishers.jbrowserdriver.JBrowserDriver.executeScript(JBrowserDriver.java:941)
at com.codeborne.selenide.Selenide.executeJavaScript(Selenide.java:381)
at com.uprr.btp.utils.Highlighter.transform(Highlighter.java:53)
at com.uprr.btp.utils.Highlighter.highlight(Highlighter.java:41)
at com.uprr.btp.utils.Highlighter.highlight(Highlighter.java:33)
at com.uprr.btp.createtrain.pageobjects.MiscPanelObjects.verifyText(MiscPanelObjects.java:97)
at com.uprr.btp.createtrain.pageobjects.MiscPanelObjects.verifyMessageText(MiscPanelObjects.java:74)
at com.uprr.btp.testcases.AddGenericMessageTest.checkDPUMessageTest(AddGenericMessageTest.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.io.NotSerializableException: com.codeborne.selenide.impl.SelenideElementProxy
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1378)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:294)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:153)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
at com.machinepublishers.jbrowserdriver.$Proxy6.executeScript(Unknown Source)
at com.machinepublishers.jbrowserdriver.JBrowserDriver.executeScript(JBrowserDriver.java:937)
... 32 more
Thanks, Anil
You're passing in WebElements which aren't serializable, but they must be to work, or they must be WebElements from jBrowserDriver.
Hey there, I have experienced the same issue as well. On other Selenium WebDriver implementations, it's possible to pass a WebElement to the executeJavaScript method. Wouldn't it be possible to add this feature to JBrowser as well?
As far as I could see, other implementations make use of the org.openqa.selenium.internal.HasIdentity interface in order to uniquely identify WebElements. This way, one would just need to pass the identity instead of the entire serialized WebElement instance.
[edit] I would be willing to contribute this, as soon as I find some time slot :)
@qqilihq Hi, passing in WebElements from jBrowserDriver are supported. That wasn't always the case so last time you tried that feature may not have been added yet. Happy to accept pull requests!
The issue is that this works using RMI. Under the hood JBrowserDriver Element uses a remote proxy object to get around the fact that JBrowserDriver ElementServer isn't serializable.
@hollingsworthd Awesome, hadn't noticed that this was fixed in the meantime! Just checked and it's working as expected for jBrowser WebElements now. Thanks for the efforts! :)
I'm running into this issue when combining jBrowserDriver with the very handy AngularJS selectors from ngWebDriver:
org.openqa.selenium.WebDriverException: com.paulhammant.ngwebdriver.ByAngularModel
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'Thomass-MacBook-Pro-Gilon.local', ip: '172.20.0.217', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.5', java.version: '1.8.0_73'
Driver info: driver.version: EventFiringWebDriver
at com.machinepublishers.jbrowserdriver.Util.handleException(Util.java:137)
at com.machinepublishers.jbrowserdriver.JBrowserDriver.findElement(JBrowserDriver.java:652)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
at com.sun.proxy.$Proxy21.findElement(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:188)
at com.company.webtest.LoginStepDefs.iEnterInvalidCredentials(LoginStepDefs.java:85)
at ✽.When I enter invalid credentials(login.feature:8)
Caused by: java.io.NotSerializableException: com.paulhammant.ngwebdriver.ByAngularModel
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:294)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:153)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
at com.machinepublishers.jbrowserdriver.$Proxy18.findElement(Unknown Source)
at com.machinepublishers.jbrowserdriver.JBrowserDriver.findElement(JBrowserDriver.java:649)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
at com.sun.proxy.$Proxy21.findElement(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:188)
at com.company.webtest.LoginStepDefs.iEnterInvalidCredentials(LoginStepDefs.java:85)
With PhantomJS/GhostDriver it is not an issue.
@tfnico that's a different problem than the bug here. I believe it will work for you if you use the v0.14.12 or v0.15.0 ... see #151 for background
@hollingsworthd That did the trick! Using 0.15.0 solves the issue. I just started using this project a week ago so I was still on 0.14.11.