Hi
I tried the code, but i am getting selenium errors here is the high
level code.
private WebDriver driver;
private Selenium selenium;
driver = new FirefoxDriver();
baseUrl = "
https://xxxxxxxxxxxxxxxx/";
selenium = new WebDriverBackedSelenium(driver, baseUrl);
.... Here I have some log in to the application code. ( Ignore this )
String function = "var win =
this.browserbot.getUserWindow();win.errors = win.errors ||
[];win.errorsJson = win.errorsJson || \"\";win.originalonerror =
win.originalonerror || win.onerror ||\"none\";win.onerror =
function(errorMsg, url, lineNumber) { win.errors.push({\"errorMsg\":
errorMsg || \"\",\"url\": url || \"\",\"lineNumber\": lineNumber ||
\"\"});if (JSON &&JSON.stringify) win.errorsJson =
JSON.stringify(win.errors); if (win.originalonerror != \"none\")
win.originalonerror(errorMsg, url, lineNumber);};win.console = {logs:
win.console.logs || [],logsJson: win.console.logsJson || \"\",log:
function() {win.console.logs.push(arguments);if (JSON &&
JSON.stringify) win.console.logsJson =
JSON.stringify(win.console.logs);},warns: win.console.warns ||
[],warnsJson: win.console.warnsJson || \"\",warn: function()
{win.console.warns.push(arguments); if (JSON && JSON.stringify)
win.console.warnsJson = JSON.stringify(win.console.warns);},errors:
win.console.errors || [],errorsJson: win.console.errorsJson ||
\"\",error: function() { win.console.errors.push(arguments);if (JSON
&& JSON.stringify) win.console.errorsJson =
JSON.stringify(win.console.errors);}};";
selenium.getEval(function); <----------
Coding failing here. (Below i have attached the failure trace for the
same )
String errorFunction =
"this.browserbot.getUserWindow().console.errorsJson";
String warningsFunction =
"this.browserbot.getUserWindow().console.warnsJson";
String exceptionFunction =
"this.browserbot.getUserWindow().errorsJson";
String logFunction =
"this.browserbot.getUserWindow().console.logsJson";
String errors = selenium.getEval(errorFunction);
String warnings = selenium.getEval(warningsFunction);
String exception = selenium.getEval(exceptionFunction);
String logs = selenium.getEval(logFunction);
System.out.println("+++++++++++++++++++++++++++++++++++++++++");
System.out.println("ERRORS :" +errors);
System.out.println("WARNS :" +warnings);
System.out.println("EXCEP :" +exception);
System.out.println("LOG :" +logs);
Failure Trace -
com.thoughtworks.selenium.SeleniumException: null (WARNING: The server
did not provide any stacktrace information)
Command duration or timeout: 1.12 seconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27
19:03:04'
System info:
os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1',
java.version: '1.6.0_20'
Driver info: driver.version: RemoteWebDriver
at
org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:
42)
at
org.openqa.selenium.internal.seleniumemulation.Timer.run(Timer.java:
39)
at
org.openqa.selenium.WebDriverCommandProcessor.execute(WebDriverCommandProcessor.java:
145)
at
org.openqa.selenium.WebDriverCommandProcessor.getString(WebDriverCommandProcessor.java:
116)
at
com.thoughtworks.selenium.DefaultSelenium.getEval(DefaultSelenium.java:
479)
at
SampleTestsForDemo.EcampusTest1.VerifyLogOutLinkPresence(EcampusTest1.java:
57)
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:45)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
42)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:
20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
68)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:
50)
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: org.openqa.selenium.WebDriverException: null (WARNING: The
server did not provide any stacktrace information)
Command duration or timeout: 1.12 seconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27
19:03:04'
System info:
os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1',
java.version: '1.6.0_20'
Driver info: driver.version: RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:
170)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:
123)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:
438)
at
org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:
353)
at
org.openqa.selenium.internal.seleniumemulation.GetEval.handleSeleneseCommand(GetEval.java:
40)
at
org.openqa.selenium.internal.seleniumemulation.GetEval.handleSeleneseCommand(GetEval.java:
1)
at
org.openqa.selenium.internal.seleniumemulation.SeleneseCommand.apply(SeleneseCommand.java:
33)
... 30 more
Could you please suggest what might be the issue.
Thanks
Raju
On Apr 30, 9:13 am, Shaba K <
shabazi...@gmail.com> wrote:
> Hi There,
>
> I havn't been able to catch any JS Errors with the function.
> Is there more to it,that i need to do at my end.
>
> It would help if you direct pls.
>
> -Shabana
>
>
>
>
>
>
>
> On Mon, Apr 30, 2012 at 3:22 AM, fschwiet <
fschw...@gmail.com> wrote:
> > Brian thanks for sharing the code, I had been doing something
> > similar. If anyone is using Selenium 2.0 from .NET and they want to
> > monitor onerror, I've put this utility code on nuget. Its a small
> > piece of code to write, but its nice to have an implementation I can
> > reuse that has test coverage.
> > Anyhow, example usage is in the test:
>
> >
https://github.com/fschwiet/SizSelCsZzz/blob/master/SizSelCsZzz.Test/...
> > The implementation only covers onerror, not console.log/warn/error,
> > see:
> >
https://github.com/fschwiet/SizSelCsZzz/blob/master/SizSelCsZzz/WebDr...