Issues with driver.getPageSource()

1,928 views
Skip to first unread message

jyo rani

unread,
Feb 15, 2013, 9:50:15 PM2/15/13
to webd...@googlegroups.com

I have a test that opens a browser and clicks on a link and validate source code of the page(during debugging i see page is open and landed on correct page)but intermittently fails on driver.getPageSource(),that's the reason I introduced sleep time so that driver can get page source ,but it didn't work either , not sure how to resolve this. Is there a better way to do this? 

I am using webdriver 2.24  version.


=================================




public static Map<String,String> getSource(WebDriver driver) throws InterruptedException
{
Map<String,String> mp = new HashMap<String,String>();

String source = driver.getPageSource(); //TEST BLOWS UP ON THIS LINE
Thread.sleep(2000);
String pageNameRegex = "s_pageName='([^']*)'";
String chanelRegex ="s_sm.channel='([^']*)'";
Pattern pagePattern = Pattern.compile(pageNameRegex);
Pattern chanelPattern = Pattern.compile(chanelRegex);

Matcher String1  = pagePattern.matcher(source);
Matcher String2 = chanelPattern.matcher(source);


                boolean foundPagePattern = String1.find();
boolean foundchanelPattern = String2.find();

String searchString1 =String1.group(1);
String searchString2 =String2.group(1);
mp.put("s_sm.pageName", searchString1);
mp.put("s_sm.channel", searchString2);

return mp;
}

Krishnan Mahadevan

unread,
Feb 15, 2013, 10:56:51 PM2/15/13
to webd...@googlegroups.com
Please include details on : 
Stacktrace
Browser flavor and version
--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

jyo rani

unread,
Feb 15, 2013, 11:15:31 PM2/15/13
to webd...@googlegroups.com
I don't see any stack trace related to this error.
I am using Chrome/24.0.1312.57 , but it happened in older chrome versions 23.0.xxx also.

And also i am using remote webdriver.

Krishnan Mahadevan

unread,
Feb 16, 2013, 12:11:53 AM2/16/13
to webd...@googlegroups.com
The ChromeDriver.log should have this info in that case. Please include its contents from the remote node.  Without much of info, am not sure how much of a help someone can provide you with. 

testingzeal

unread,
Feb 16, 2013, 8:50:14 AM2/16/13
to webd...@googlegroups.com
Attached is the chromedriver.log, In this test i am opening 2 url's (similar kind with diff categories) and submitting a request.One request was submitted successfully and it blew up on second url,front is looking good to me.


Thanks


To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+unsubscribe@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+unsubscribe@googlegroups.com.

To post to this group, send email to webd
chromedriverlog.txt

darrell

unread,
Feb 16, 2013, 4:02:05 PM2/16/13
to webdriver
What does "BLOWS UP" mean? Does it hang for a while? How long do you
wait? Often if I have something which hangs for a while I'll go work
on something else or go for lunch. If I come back and it is still hung
that is serious. Hopefully after 10 to 30 seconds it comes back with a
stacktrace. Sometimes there might be multiple timeouts and I could be
waiting for a few minutes. I see a lot of people waiting 2 or 3
seconds then killing it. Waiting 2 or 3 seconds really doesn't give it
enough time. If I want for a few minutes the stacktrace can often give
me enough information that I save an hour trying to debug it. It also
helps me prevent the same mistake again in the future. In other words,
spending a few minutes now can often save you hours over time.

There is no context for this method. If you write a standalone method
that just has:

class GoogleThread8ca6022cde58782e {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("enter your URL here");
Map<String,String> page =
GoogleThread8ca6022cde58782e.getSource(driver);
}

// enter your getSource method here
}

Add the appropriate Selenium libraries to the project, add the
appropriate import statements to this class, get it to compile and run
it as a Java application.

If this still "BLOWS UP" then make sure you are adding all the right
libraries to your project. Make sure that the first ChromeDriver.exe
it finds in your %PATH% is the correct ChromeDriver.exe (remember, if
you copied version 17 into C:\Windows\System32 it will find that
version before it finds the version you want). If this application
works (and I suspect it will) then try adding a little more and a
little more until it "BLOWS UP". Hopefully, when you add in that last
thing which makes it "BLOWS UP" it will be obvious why it isn't work
and what you need to do to fix it.

Darrell

testingzeal

unread,
Feb 16, 2013, 8:59:39 PM2/16/13
to webd...@googlegroups.com
Sorry for not giving clear details ,Below are the complete details of the problem.
============================================================
I was have chrome driver version of 22.0.1203.0b and test is using Chrome Browser 24.0.1312.57... not sure if this is the problem

Now I upgraded my chrome driver to 26.0.1383.0


BLOWS UP MEANS******** It goes to this line (String source = driver.getPageSource(); ) AND INTERMETTINETLY IT HITS CATCH BLOCK OF THE TEST Immediately,am unable to see what's going on here.

NOTE -++++++++++++++++++++++++++++++++++++++
I am running tests as a suite not sure if tests are competing with each other as all the tests use the getSourcemethod(),every time it blows up on different page/different test.Really confused what to do here as same issue happens on diff pages/tests every time.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Below is the structure of the test.

//METHOD 

public static Map<String,String> getSource(WebDriver driver) throws InterruptedException
{
Map<String,String> mp = new HashMap<String,String>();

String source = driver.getPageSource(); //BLOWS UP MEANS******** IT GOES TO THIS LINE AND INTERMETTINETLY IT HITS CATCH BLOCK OF THE TEST,AM UNABLE TO SEE WHAT IS GOING ON HERE
Thread.sleep(2000);
String pageNameRegex = "s_pageName='([^']*)'";
String chanelRegex ="s_sm.channel='([^']*)'";
Pattern pagePattern = Pattern.compile(pageNameRegex);
Pattern chanelPattern = Pattern.compile(chanelRegex);

Matcher String1  = pagePattern.matcher(source);
Matcher String2 = chanelPattern.matcher(source);


                boolean foundPagePattern = String1.find();
boolean foundchanelPattern = String2.find();

String searchString1 =String1.group(1);
String searchString2 =String2.group(1);
mp.put("s_sm.pageName", searchString1);
mp.put("s_sm.channel", searchString2);

return mp;
}


//Calling get source method 

public static String homePageSource(WebDriver driver) throws InterruptedException
{
Map<String,String> mp = new HashMap<String,String>();
mp=getSource(driver); // CALLING GET SOURCE METHOD HERE *******************

String sm_page= mp.get("s_sm.pageName");
String sm_chanel= mp.get("s_sm.channel");

if (!sm_page.equals("abcd")|| !sm_chanel.equals("tyui")
{
String run_log ="Home Page,";
return run_log;
}
else
{
return "";

}
}


//Test

try
            {
                  driver = getDriverByBrowserType(browserType,os);
                  //From Home page submit requests for above tasks - 2 iterations
                  for (String task : taskList)  
                  {  
                         driver.get(Url);
                        platform = BrowserTypeandVersion.getOperatingSystem(driver);
                        hostName = GetHostName.getHostName(((RemoteWebDriver) driver).getSessionId());
                        run_log =xxxxx.homePageSource(driver);
                        
                       REST OF THE CODE *************************
                       }

            }
            catch (Exception e) { // HITS CATCH BLOCK 
                  driver.getCurrentUrl();
                  
            }
            finally
            {
                  driver.quit();
            }

==================================

Krishnan Mahadevan

unread,
Feb 16, 2013, 9:24:50 PM2/16/13
to webd...@googlegroups.com
Either do a e.printStackTrace() or get rid of the try catch and pls share the stacktrace. You seem to be gobbling up the exception
--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

testingzeal

unread,
Feb 16, 2013, 10:11:36 PM2/16/13
to webd...@googlegroups.com
Thanks Krishnan! And of course i am unable to reproduce the error printstacktrace(),but i'll run it tomorrow and monday and am sure it will reappear again.I'll keep you posted.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+unsubscribe@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

testingzeal

unread,
Feb 18, 2013, 4:47:42 PM2/18/13
to webd...@googlegroups.com
I got this NoSuchElementException - Below is the complete stack trace, This happens on different pages each time.Actually all the elements are there.Is there a way to get around this? 


=========================================
org.openqa.selenium.NoSuchElementException: The element could not be found (WARNING: The server did not provide any stacktrace informa
Command duration or timeout: 43 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 17:28:14'
System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0'
Driver info: driver.version: EventFiringWebDriver
Session ID: 64e2ad4e0e915c49239e7e34945cdb1a
Command duration or timeout: 359 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49'
System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
Session ID: 1361212119582
        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:188)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242)
        at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:319)
        at org.openqa.selenium.By$ByCssSelector.findElement(By.java:405)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:234)
        at com.servicemagic.selenium.util.OmnitureHelper.validateManualSR(OmnitureHelper.java:1353)
        at com.servicemagic.selenium.util.OmnitureHelper.submitSR(OmnitureHelper.java:1005)
        at com.homeadvisor.selenium.omnituresrpaths.OmnitureMMRSRPathTest.runTest(OmnitureMMRSRPathTest.java:93)
        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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
        at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:73)
        at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:14)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49'
System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:125)
        ... 22 more
Caused by: org.openqa.selenium.NoSuchElementException: The element could not be found (WARNING: The server did not provide any stacktr

Command duration or timeout: 43 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 17:28:14'
System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0'
Driver info: driver.version: EventFiringWebDriver
Session ID: 64e2ad4e0e915c49239e7e34945cdb1a
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49'
System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2', java.version: '1.6.0_26'
Driver info: driver.version: EventFiringWebDriver
        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:188)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242)
        at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:319)
        at org.openqa.selenium.By$ByCssSelector.findElement(By.java:406)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:234)
        at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101)
        at $Proxy1.findElement(Unknown Source)
        at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:180)
        at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:47)
        at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:150)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
==================

testingzeal

unread,
Feb 18, 2013, 8:42:59 PM2/18/13
to webd...@googlegroups.com
I am seeing 2 issues on stacktrace 

1. org.openqa.selenium.NoSuchElementException: The element could not be found (WARNING: The server did not provide any stacktrace informa
Command duration or timeout: 43 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html - IT HAPPENS INTERMITTENTLY ON DIFFERENT PAGES

2.Reg to driver.getpagesource() error - Here is the stack trace 

Again this happens on different pages each time, I think this is also timing issue 


java.lang.IllegalStateException: No match found
        at java.util.regex.Matcher.group(Matcher.java:468)
        at com.servicemagic.selenium.util.xxxxx.getSource(xxxxxx.java:40)
        at com.servicemagic.selenium.util.xxxxx.getSource(xxxxr.java:366)
        at com.cxcxcx.selenium.vcbvcbvbb.vvcxvcvcvcvTest.runTest(bvbvbvbvbbb.java:66)
        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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
        at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:73)
        at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:14)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)



Thanks!



To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

Mark Collin

unread,
Feb 19, 2013, 1:24:52 AM2/19/13
to webd...@googlegroups.com

If you are getting intermittent NoSuchElementExceptions you have badly written test cases and you need to start using explicit waits:

 

http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-and-implicit-waits

 

As to your second error, I’m not sure.  I would need to see your code to be able to guess.

=========================================

To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

testingzeal

unread,
Feb 19, 2013, 9:37:16 AM2/19/13
to webd...@googlegroups.com
Mark,

Here is the code for second error stack trace - No match found ..this is intermittent error , it happens on different pages each time.

public static Map<String,String> getSource(WebDriver driver) throws InterruptedException
{
Map<String,String> mp = new HashMap<String,String>();

String source = driver.getPageSource(); //BLOWS UP MEANS******** IT GOES TO THIS LINE AND INTERMETTINETLY IT HITS CATCH BLOCK OF THE TEST,AM UNABLE TO SEE WHAT IS GOING ON HERE
Thread.sleep(2000);
String pageNameRegex = "s_pageName='([^']*)'";
String chanelRegex ="s_sm.channel='([^']*)'";
Pattern pagePattern = Pattern.compile(pageNameRegex);
Pattern chanelPattern = Pattern.compile(chanelRegex);

Matcher String1  = pagePattern.matcher(source);
Matcher String2 = chanelPattern.matcher(source);


                boolean foundPagePattern = String1.find();
boolean foundchanelPattern = String2.find();

String searchString1 =String1.group(1);
String searchString2 =String2.group(1);
mp.put("s_sm.pageName", searchString1);
mp.put("s_sm.channel", searchString2);

return mp;
}
java.lang.IllegalStateException: No match found

        at java.util.regex.Matcher.group(Matcher.java:468)

        at com.servicemagic.selenium.util.xxxxx.getSource(xxxxxx.java:40)

        at com.servicemagic.selenium.util.xxxxx.getSource(xxxxr.java:366)

        at com.cxcxcx.selenium.vcbvcbvbb.vvcxvcvcvcvTest.runTest(bvbvbvbvbbb.java:66)

        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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)

        at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)

        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)

        at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:73)

        at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:14)

        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

        at java.util.concurrent.FutureTask.run(FutureTask.java:138)

        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

 Thanks!

Mark Collin

unread,
Feb 19, 2013, 11:30:21 AM2/19/13
to webd...@googlegroups.com
Get rid of the Thread.sleep, it is pointless.

I would suggest looking at your code that when you get the page source it has not loaded whatever you are looking for with your regex.� There is nothing in that code to suggest that you are waiting for the page to load correctly (which is why in my previous post I told you to look at explicit waits).

What are you trying to do with the regex?� Pulling the entire page source and then running regex across it seems like a slow and inaccurate way to do things, what is your intent?



On 19/02/2013 14:37, testingzeal wrote:
Mark,

Here is the code for second error stack trace - No match found ..this is intermittent error , it happens on different pages each time.

public static Map<String,String> getSource(WebDriver driver) throws InterruptedException
{
Map<String,String> mp = new HashMap<String,String>();

String source = driver.getPageSource(); //BLOWS UP MEANS******** IT GOES TO THIS LINE AND INTERMETTINETLY IT HITS CATCH BLOCK OF THE TEST,AM UNABLE TO SEE WHAT IS GOING ON HERE
Thread.sleep(2000);
String pageNameRegex = "s_pageName='([^']*)'";
String chanelRegex ="s_sm.channel='([^']*)'";
Pattern pagePattern = Pattern.compile(pageNameRegex);
Pattern chanelPattern = Pattern.compile(chanelRegex);

Matcher String1 �= pagePattern.matcher(source);
Matcher String2 = chanelPattern.matcher(source);


� � � � � � � � boolean foundPagePattern = String1.find();
boolean foundchanelPattern = String2.find();

String searchString1 =String1.group(1);
String searchString2 =String2.group(1);
mp.put("s_sm.pageName", searchString1);
mp.put("s_sm.channel", searchString2);

return mp;
}
java.lang.IllegalStateException: No match found

� � � � at java.util.regex.Matcher.group(Matcher.java:468)

� � � � at com.servicemagic.selenium.util.xxxxx.getSource(xxxxxx.java:40)

� � � � at com.servicemagic.selenium.util.xxxxx.getSource(xxxxr.java:366)

� � � � at com.cxcxcx.selenium.vcbvcbvbb.vvcxvcvcvcvTest.runTest(bvbvbvbvbbb.java:66)

� � � � 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)

� � � � at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)

� � � � at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)

� � � � at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:73)

� � � � at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:14)

� � � � at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

� � � � at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

� � � � at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

�Thanks!

On Monday, February 18, 2013 11:24:52 PM UTC-7, Mark Collin wrote:

If you are getting intermittent NoSuchElementExceptions you have badly written test cases and you need to start using explicit waits:

�

http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-and-implicit-waits

�

As to your second error, I�m not sure.� I would need to see your code to be able to guess.

�

From: webd...@googlegroups.com [mailto:webd...@googlegroups.com] On Behalf Of testingzeal
Sent: 19 February 2013 01:43
To: webd...@googlegroups.com
Subject: Re: [webdriver] Issues with driver.getPageSource()

�

I am seeing 2 issues on stacktrace�

�

1. org.openqa.selenium.NoSuchElementException: The element could not be found (WARNING: The server did not provide any stacktrace informa

Command duration or timeout: 43 milliseconds

For documentation on this error, please visit:�http://seleniumhq.org/exceptions/no_such_element.html - IT HAPPENS INTERMITTENTLY ON DIFFERENT PAGES

�

2.Reg to driver.getpagesource() error - Here is the stack trace�

�

Again this happens on different pages each time, I think this is also timing issue�

�

�

java.lang.IllegalStateException: No match found

� � � � at java.util.regex.Matcher.group(Matcher.java:468)

� � � � at com.servicemagic.selenium.util.xxxxx.getSource(xxxxxx.java:40)

� � � � at com.servicemagic.selenium.util.xxxxx.getSource(xxxxr.java:366)

� � � � at com.cxcxcx.selenium.vcbvcbvbb.vvcxvcvcvcvTest.runTest(bvbvbvbvbbb.java:66)

� � � � 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)

� � � � at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)

� � � � at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)

� � � � at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:73)

� � � � at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:14)

� � � � at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

� � � � at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

� � � � at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

�

�

�

Thanks!

�

�

�

On Mon, Feb 18, 2013 at 2:47 PM, testingzeal <jsel...@gmail.com> wrote:

I got this�NoSuchElementException - Below is the complete stack trace, This happens on different pages each time.Actually all the elements are there.Is there a way to get around this?�

�

�

=========================================

org.openqa.selenium.NoSuchElementException: The element could not be found (WARNING: The server did not provide any stacktrace informa

Command duration or timeout: 43 milliseconds

For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 17:28:14'

System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0'

Driver info: driver.version: EventFiringWebDriver

Session ID: 64e2ad4e0e915c49239e7e34945cdb1a

Command duration or timeout: 359 milliseconds

For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49'

System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2', java.version: '1.6.0_26'

Driver info: driver.version: RemoteWebDriver

Session ID: 1361212119582

� � � � 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:188)

� � � � at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)

� � � � at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)

� � � � at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242)

� � � � at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:319)

� � � � at org.openqa.selenium.By$ByCssSelector.findElement(By.java:405)

� � � � at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:234)

� � � � at com.servicemagic.selenium.util.OmnitureHelper.validateManualSR(OmnitureHelper.java:1353)

� � � � at com.servicemagic.selenium.util.OmnitureHelper.submitSR(OmnitureHelper.java:1005)

� � � � at com.homeadvisor.selenium.omnituresrpaths.OmnitureMMRSRPathTest.runTest(OmnitureMMRSRPathTest.java:93)

� � � � 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)

� � � � at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)

� � � � at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)

� � � � at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:73)

� � � � at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:14)

� � � � at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

� � � � at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

� � � � at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

� � � � at java.lang.Thread.run(Thread.java:662)

Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49'

System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2', java.version: '1.6.0_26'

Driver info: driver.version: RemoteWebDriver

� � � � at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:125)

� � � � ... 22 more

Caused by: org.openqa.selenium.NoSuchElementException: The element could not be found (WARNING: The server did not provide any stacktr

�

Command duration or timeout: 43 milliseconds

For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 17:28:14'

System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0'

Driver info: driver.version: EventFiringWebDriver

Session ID: 64e2ad4e0e915c49239e7e34945cdb1a

For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49'

System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2', java.version: '1.6.0_26'

Driver info: driver.version: EventFiringWebDriver

� � � � 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:188)

� � � � at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)

� � � � at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)

� � � � at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242)

� � � � at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:319)

� � � � at org.openqa.selenium.By$ByCssSelector.findElement(By.java:406)

� � � � at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:234)

� � � � at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)

� � � � at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

� � � � at java.lang.reflect.Method.invoke(Method.java:597)

� � � � at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101)

� � � � at $Proxy1.findElement(Unknown Source)

� � � � at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:180)

� � � � at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:47)

� � � � at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1)

� � � � at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

� � � � at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:150)

� � � � at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)

� � � � at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)

� � � � at java.lang.Thread.run(Thread.java:619)

==================


On Saturday, February 16, 2013 8:11:36 PM UTC-7, testingzeal wrote:

Thanks Krishnan! And of course i am unable to reproduce the error printstacktrace(),but i'll run it tomorrow and monday and am sure it will reappear again.I'll keep you posted.

On Saturday, February 16, 2013 7:24:50 PM UTC-7, Krishnan wrote:

Either do a e.printStackTrace() or get rid of the try catch and pls share the stacktrace. You seem to be gobbling up the exception

On Sunday, February 17, 2013, testingzeal wrote:

Sorry for not giving clear details ,Below are the complete details of the problem.

============================================================

I was have chrome driver version of 22.0.1203.0b and test is using Chrome Browser 24.0.1312.57... not sure if this is the problem

�

Now I upgraded my chrome driver to 26.0.1383.0

�

�

BLOWS UP MEANS******** It goes to this line (String source = driver.getPageSource(); ) AND INTERMETTINETLY IT HITS CATCH BLOCK OF THE TEST Immediately,am unable to see what's going on here.

�

NOTE -++++++++++++++++++++++++++++++++++++++

I am running tests as a suite not sure if tests are competing with each other as all the tests use the getSourcemethod(),every time it blows up on different page/different test.Really confused what to do here as same issue happens on diff pages/tests every time.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

�

Below is the structure of the test.

�

//METHOD�

�

public static Map<String,String> getSource(WebDriver driver) throws InterruptedException

{

Map<String,String> mp = new HashMap<String,String>();

�

String source = driver.getPageSource(); //BLOWS UP MEANS******** IT GOES TO THIS LINE AND INTERMETTINETLY IT HITS CATCH BLOCK OF THE TEST,AM UNABLE TO SEE WHAT IS GOING ON HERE

Thread.sleep(2000);

String pageNameRegex = "s_pageName='([^']*)'";

String chanelRegex ="s_sm.channel='([^']*)'";

Pattern pagePattern = Pattern.compile(pageNameRegex);

Pattern chanelPattern = Pattern.compile(chanelRegex);

�

Matcher String1 �= pagePattern.matcher(source);

Matcher String2 = chanelPattern.matcher(source);

�

�

� � � � � � � � boolean foundPagePattern = String1.find();

boolean foundchanelPattern = String2.find();

�

String searchString1 =String1.group(1);

String searchString2 =String2.group(1);

mp.put("s_sm.pageName", searchString1);

mp.put("s_sm.channel", searchString2);

�

return mp;

}

�

�

//Calling get source method�

�

public static String homePageSource(WebDriver driver) throws InterruptedException

{

Map<String,String> mp = new HashMap<String,String>();

mp=getSource(driver); // CALLING GET SOURCE METHOD HERE *******************

�

String sm_page= mp.get("s_sm.pageName");

String sm_chanel= mp.get("s_sm.channel");

�

if (!sm_page.equals("abcd")|| !sm_chanel.equals("tyui")

{

String run_log ="Home Page,";

return run_log;

}

else

{

return "";

�

}

}

�

�

//Test

�

try

� � � � � � {

� � � � � � � � � driver = getDriverByBrowserType(browserType,os);

� � � � � � � � � //From Home page submit requests for above tasks - 2 iterations

� � � � � � � � � for (String task : taskList) �

� � � � � � � � � { �

� � � � � � � � � � � � �driver.get(Url);

� � � � � � � � � � � � platform = BrowserTypeandVersion.getOperatingSystem(driver);

� � � � � � � � � � � � hostName = GetHostName.getHostName(((RemoteWebDriver) driver).getSessionId());

� � � � � � � � � � � � run_log =xxxxx.homePageSource(driver);

� � � � � � � � � � � ��

� � � � � � � � � � � �REST OF THE CODE *************************

� � � � � � � � � � � �}

�

� � � � � � }

� � � � � � catch (Exception e) { // HITS CATCH BLOCK�

� � � � � � � � � driver.getCurrentUrl();

� � � � � � � � ��

� � � � � � }

� � � � � � finally

� � � � � � {

� � � � � � � � � driver.quit();

� � � � � � }

�

==================================


On Saturday, February 16, 2013 2:02:05 PM UTC-7, darrell wrote:

What does "BLOWS UP" mean? Does it hang for a while? How long do you
wait? Often if I have something which hangs for a while I'll go work
on something else or go for lunch. If I come back and it is still hung
that is serious. Hopefully after 10 to 30 seconds it comes back with a
stacktrace. Sometimes there might be multiple timeouts and I could be
waiting for a few minutes. I see a lot of people waiting 2 or 3
seconds then killing it. Waiting 2 or 3 seconds really doesn't give it
enough time. If I want for a few minutes the stacktrace can often give
me enough information that I save an hour trying to debug it. It also
helps me prevent the same mistake again in the future. In other words,
spending a few minutes now can often save you hours over time.

There is no context for this method. If you write a standalone method
that just has:

class GoogleThread8ca6022cde58782e {

� � public static void main(String[] args) {
� � � � WebDriver driver = new ChromeDriver();
� � � � driver.get("enter your URL here");
� � � � Map<String,String> page =
GoogleThread8ca6022cde58782e.getSource(driver);
� � }

� � // enter your getSource method here

}

Add the appropriate Selenium libraries to the project, add the
appropriate import statements to this class, get it to compile and run
it as a Java application.

If this still "BLOWS UP" then make sure you are adding all the right
libraries to your project. Make sure that the first ChromeDriver.exe
it finds in your %PATH% is the correct ChromeDriver.exe (remember, if
you copied version 17 into C:\Windows\System32 it will find that
version before it finds the version you want). If this application
works (and I suspect it will) then try adding a little more and a
little more until it "BLOWS UP". Hopefully, when you add in that last
thing which makes it "BLOWS UP" it will be obvious why it isn't work
and what you need to do to fix it.

Darrell


On Feb 15, 9:50�pm, jyo rani <jselen...@gmail.com> wrote:
> I have a test that opens a browser and clicks on a link and validate source
> code of the page(during debugging i see page is open and landed on correct
> page)but intermittently fails on driver.getPageSource(),that's the reason I
> introduced sleep time so that driver can get page source ,but it didn't
> work either , not sure how to resolve this. Is there a better way to do
> this?
>

> I am using webdriver 2.24 �version.

>
> =================================
>
> public static Map<String,String> getSource(WebDriver driver) throws
> InterruptedException
> {
> Map<String,String> mp = new HashMap<String,String>();
>
> String source = driver.getPageSource(); //TEST BLOWS UP ON THIS LINE
> Thread.sleep(2000);
> String pageNameRegex = "s_pageName='([^']*)'";
> String chanelRegex ="s_sm.channel='([^']*)'";

> �Pattern pagePattern = Pattern.compile(pageNameRegex);
> Pattern chanelPattern = Pattern.compile(chanelRegex);
>
> Matcher String1 �= pagePattern.matcher(source);
> Matcher String2 = chanelPattern.matcher(source);
>
> � � � � � � � � boolean foundPagePattern = String1.find();

> boolean foundchanelPattern = String2.find();
>
> String searchString1 =String1.group(1);
> String searchString2 =String2.group(1);

> �mp.put("s_sm.pageName", searchString1);

> mp.put("s_sm.channel", searchString2);
>
> return mp;
>
>
>
>
>
>
>
> }

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

�
�



--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

�
�

�

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

�
�

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
�
�

testingzeal

unread,
Feb 19, 2013, 12:32:49 PM2/19/13
to webd...@googlegroups.com
My intent here is looking for some expected strings on page source and if they exists continue to next page else report that expected string is not there.

My test case is submitting a request .. It is a 5 page process to submit a request , on each and every page i need to look for some expected strings. if they exist continue else fail the test and report the url where the expected string is missing.

What is the better way to do this if not getting pagesource and running regex against it?

Thanks!

Mark Collin

unread,
Feb 19, 2013, 4:23:40 PM2/19/13
to webd...@googlegroups.com
I would look for the element that contains the string and then use
getText(). You can then also easily set an explicit wait until that element
exists on the page.



You are basically using a Gatling Gun when a Sniper Rifle would be more
appropriate, and more likely to hit what you want to hit.



From: webd...@googlegroups.com [mailto:webd...@googlegroups.com] On
Behalf Of testingzeal
Sent: 19 February 2013 17:33
To: webd...@googlegroups.com
Subject: Re: [webdriver] Issues with driver.getPageSource()



)



� � � � at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
<http://seleniumhq.org/exceptions/no_such_element.html> l - IT HAPPENS
INTERMITTENTLY ON DIFFERENT PAGES

�

2.Reg to driver.getpagesource() error - Here is the stack trace�

�

Again this happens on different pages each time, I think this is also timing
issue�

�

�

java.lang.IllegalStateException: No match found

� � � � at java.util.regex.Matcher.group(Matcher.java:468)

� � � � at
com.servicemagic.selenium.util.xxxxx.getSource(xxxxxx.java:40)

� � � � at
com.servicemagic.selenium.util.xxxxx.getSource(xxxxr.java:366)

� � � � at
com.cxcxcx.selenium.vcbvcbvbb.vvcxvcvcvcvTest.runTest(bvbvbvbvbbb.java:66)

� � � � 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelp
er.java:80)

� � � � at
org.testng.internal.Invoker.invokeMethod(Invoker.java:691)

� � � � at
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)

� � � � at
org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWi
thDataProviderMethodWorker.java:73)

� � � � at
org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWi
thDataProviderMethodWorker.java:14)

� � � � at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
va:886)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9
08)

sorImpl.java:39)

� � � � at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc
torAccessorImpl.java:27)

� � � � at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)

� � � � at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:18
8)

� � � � at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.j
ava:145)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:
242)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWe
bDriver.java:319)

� � � � at
org.openqa.selenium.By$ByCssSelector.findElement(By.java:405)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:
234)

� � � � at
com.servicemagic.selenium.util.OmnitureHelper.validateManualSR(OmnitureHelpe
r.java:1353)

� � � � at
com.servicemagic.selenium.util.OmnitureHelper.submitSR(OmnitureHelper.java:1
005)

� � � � at
com.homeadvisor.selenium.omnituresrpaths.OmnitureMMRSRPathTest.runTest(Omnit
ureMMRSRPathTest.java:93)

� � � � 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelp
er.java:80)

� � � � at
org.testng.internal.Invoker.invokeMethod(Invoker.java:691)

� � � � at
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)

� � � � at
org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWi
thDataProviderMethodWorker.java:73)

� � � � at
org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWi
thDataProviderMethodWorker.java:14)

� � � � at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
va:886)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9
08)

sorImpl.java:39)

� � � � at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc
torAccessorImpl.java:27)

� � � � at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)

� � � � at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:18
8)

� � � � at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.j
ava:145)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:
242)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWe
bDriver.java:319)

� � � � at
org.openqa.selenium.By$ByCssSelector.findElement(By.java:406)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:
234)

� � � � at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown
Source)

� � � � at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

� � � � at java.lang.reflect.Method.invoke(Method.java:597)

� � � � at
org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiring
WebDriver.java:101)

� � � � at $Proxy1.findElement(Unknown Source)

� � � � at
org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFir
ingWebDriver.java:180)

� � � � at
org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:
47)

� � � � at
org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:
1)

� � � � at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

� � � � at
org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:1
50)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
email to webdriver+...@googlegroups.com <javascript:> .
To post to this group, send email to webd...@googlegroups.com <javascript:>

testingzeal

unread,
Feb 19, 2013, 6:15:40 PM2/19/13
to webd...@googlegroups.com
String i am looking exists only in the page source and it is not tied to any locator.

Do you mean this is more accurate way?

driver.getPageSource().contains("your text");
not sure how to tie pagesource() and gettext()....

Bill Ross

unread,
Feb 19, 2013, 7:16:46 PM2/19/13
to webd...@googlegroups.com
FWIW I'm not sure page source is an accurate picture of the DOM, it
might be only the originally loaded source.

Bill

Mark Collin <mark....@lazeryattack.com> wrote:

> Get rid of the Thread.sleep, it is pointless.
>
> I would suggest looking at your code that when you get the page source
> it has not loaded whatever you are looking for with your regex. There
> is nothing in that code to suggest that you are waiting for the page to
> load correctly (which is why in my previous post I told you to look at
> explicit waits).
>
> What are you trying to do with the regex? Pulling the entire page
> source and then running regex across it seems like a slow and inaccurate
> way to do things, what is your intent?
>
>
> On 19/02/2013 14:37, testingzeal wrote:
> > Mark,
> >
> > Here is the code for second error stack trace - No match found ..this
> > is intermittent error , it happens on different pages each time.
> >
> > public static Map<String,String> getSource(WebDriver driver) throws
> > InterruptedException
> > {
> > Map<String,String> mp = new HashMap<String,String>();
> >
> > String source = driver.getPageSource(); //BLOWS UP MEANS******** IT
> > GOES TO THIS LINE AND INTERMETTINETLY IT HITS CATCH BLOCK OF THE
> > TEST,AM UNABLE TO SEE WHAT IS GOING ON HERE
> > Thread.sleep(2000);
> > String pageNameRegex = "s_pageName='([^']*)'";
> > String chanelRegex ="s_sm.channel='([^']*)'";
> > Pattern pagePattern = Pattern.compile(pageNameRegex);
> > Pattern chanelPattern = Pattern.compile(chanelRegex);
> >
> > Matcher String1 = pagePattern.matcher(source);
> > Matcher String2 = chanelPattern.matcher(source);
> >
> >
> > boolean foundPagePattern = String1.find();
> > boolean foundchanelPattern = String2.find();
> >
> > String searchString1 =String1.group(1);
> > String searchString2 =String2.group(1);
> > mp.put("s_sm.pageName", searchString1);
> > mp.put("s_sm.channel", searchString2);
> >
> > return mp;
> > }
> > java.lang.IllegalStateException: No match found
> >
> > Thanks!
> >
> > On Monday, February 18, 2013 11:24:52 PM UTC-7, Mark Collin wrote:
> >
> > If you are getting intermittent NoSuchElementExceptions you have
> > badly written test cases and you need to start using explicit waits:
> >
> > http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-and-implicit-waits
> > <http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-and-implicit-waits>
> >
> > As to your second error, I’m not sure. I would need to see your
> > code to be able to guess.
> >
> > *From:*webd...@googlegroups.com <javascript:>
> > [mailto:webd...@googlegroups.com <javascript:>] *On Behalf Of
> > *testingzeal
> > *Sent:* 19 February 2013 01:43
> > *To:* webd...@googlegroups.com <javascript:>
> > *Subject:* Re: [webdriver] Issues with driver.getPageSource()
> >
> > I am seeing 2 issues on stacktrace
> >
> > 1. org.openqa.selenium.NoSuchElementException: The element could
> > not be found (WARNING: The server did not provide any stacktrace
> > informa
> >
> > Command duration or timeout: 43 milliseconds
> >
> > For documentation on this error, please visit:
> > http://seleniumhq.org/exceptions/no_such_element.htm
> > <http://seleniumhq.org/exceptions/no_such_element.html>l - IT
> > HAPPENS INTERMITTENTLY ON DIFFERENT PAGES
> >
> > 2.Reg to driver.getpagesource() error - Here is the stack trace
> >
> > Again this happens on different pages each time, I think this is
> > On Mon, Feb 18, 2013 at 2:47 PM, testingzeal <jsel...@gmail.com
> > <javascript:>> wrote:
> >
> > I got this NoSuchElementException - Below is the complete stack
> > trace, This happens on different pages each time.Actually all the
> > elements are there.Is there a way to get around this?
> >
> > =========================================
> >
> > org.openqa.selenium.NoSuchElementException: The element could not
> > be found (WARNING: The server did not provide any stacktrace informa
> >
> > Command duration or timeout: 43 milliseconds
> >
> > For documentation on this error, please visit:
> > http://seleniumhq.org/exceptions/no_such_element.html
> > <http://seleniumhq.org/exceptions/no_such_element.html>
> >
> > Build info: version: '2.24.1', revision: '17205', time:
> > '2012-06-19 17:28:14'
> >
> > System info: os.name <http://os.name>: 'Windows Vista', os.arch:
> > 'x86', os.version: '6.1', java.version: '1.6.0'
> >
> > Driver info: driver.version: EventFiringWebDriver
> >
> > Session ID: 64e2ad4e0e915c49239e7e34945cdb1a
> >
> > Command duration or timeout: 359 milliseconds
> >
> > For documentation on this error, please visit:
> > http://seleniumhq.org/exceptions/no_such_element.html
> > <http://seleniumhq.org/exceptions/no_such_element.html>
> >
> > Build info: version: '2.24.1', revision: '17205', time:
> > '2012-06-19 15:28:49'
> >
> > System info: os.name <http://os.name>: 'Windows 2003', os.arch:
> > 'x86', os.version: '5.2', java.version: '1.6.0_26'
> >
> > Driver info: driver.version: RemoteWebDriver
> >
> > Session ID: 1361212119582
> >
> > 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:188)
> >
> > at
> > org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
> >
> > at
> > org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
> >
> > at
> > org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242)
> >
> > at
> > org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:319)
> >
> > at org.openqa.selenium.By
> > <http://org.openqa.selenium.By>$ByCssSelector.findElement(By.java:405)
> > at java.lang.Thread.run(Thread.java:662)
> >
> > Caused by: org.openqa.selenium.remote.ScreenshotException: Screen
> > shot has been taken
> >
> > Build info: version: '2.24.1', revision: '17205', time:
> > '2012-06-19 15:28:49'
> >
> > System info: os.name <http://os.name>: 'Windows 2003', os.arch:
> > 'x86', os.version: '5.2', java.version: '1.6.0_26'
> >
> > Driver info: driver.version: RemoteWebDriver
> >
> > at
> > org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:125)
> >
> > ... 22 more
> >
> > Caused by: org.openqa.selenium.NoSuchElementException: The element
> > could not be found (WARNING: The server did not provide any stacktr
> >
> > Command duration or timeout: 43 milliseconds
> >
> > For documentation on this error, please visit:
> > http://seleniumhq.org/exceptions/no_such_element.html
> > <http://seleniumhq.org/exceptions/no_such_element.html>
> >
> > Build info: version: '2.24.1', revision: '17205', time:
> > '2012-06-19 17:28:14'
> >
> > System info: os.name <http://os.name>: 'Windows Vista', os.arch:
> > 'x86', os.version: '6.1', java.version: '1.6.0'
> >
> > Driver info: driver.version: EventFiringWebDriver
> >
> > Session ID: 64e2ad4e0e915c49239e7e34945cdb1a
> >
> > For documentation on this error, please visit:
> > http://seleniumhq.org/exceptions/no_such_element.html
> > <http://seleniumhq.org/exceptions/no_such_element.html>
> >
> > Build info: version: '2.24.1', revision: '17205', time:
> > '2012-06-19 15:28:49'
> >
> > System info: os.name <http://os.name>: 'Windows 2003', os.arch:
> > 'x86', os.version: '5.2', java.version: '1.6.0_26'
> >
> > Driver info: driver.version: EventFiringWebDriver
> >
> > 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:188)
> >
> > at
> > org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
> >
> > at
> > org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
> >
> > at
> > org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242)
> >
> > at
> > org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:319)
> >
> > at org.openqa.selenium.By
> > <http://org.openqa.selenium.By>$ByCssSelector.findElement(By.java:406)
> > at java.lang.Thread.run(Thread.java:619)
> >
> > ==================
> >
> >
> > On Saturday, February 16, 2013 8:11:36 PM UTC-7, testingzeal wrote:
> >
> > Thanks Krishnan! And of course i am unable to reproduce the error
> > printstacktrace(),but i'll run it tomorrow and monday and am sure
> > it will reappear again.I'll keep you posted.
> >
> > On Saturday, February 16, 2013 7:24:50 PM UTC-7, Krishnan wrote:
> >
> > Either do a e.printStackTrace() or get rid of the try catch and
> > pls share the stacktrace. You seem to be gobbling up the exception
> >
> > On Sunday, February 17, 2013, testingzeal wrote:
> >
> > Sorry for not giving clear details ,Below are the complete details
> > of the problem.
> >
> > ============================================================
> >
> > I was have chrome driver version of 22.0.1203.0b and test is using
> > Chrome Browser 24.0.1312.57... not sure if this is the problem
> >
> > Now I upgraded my chrome driver to 26.0.1383.0
> >
> > BLOWS UP MEANS******** It goes to this line (String source =
> > driver.getPageSource(); ) AND INTERMETTINETLY IT HITS CATCH BLOCK
> > OF THE TEST Immediately,am unable to see what's going on here.
> >
> > NOTE -++++++++++++++++++++++++++++++++++++++
> >
> > I am running tests as a suite not sure if tests are competing with
> > each other as all the tests use the getSourcemethod(),every time
> > it blows up on different page/different test.Really confused what
> > to do here as same issue happens on diff pages/tests every time.
> >
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Below is the structure of the test.
> >
> > //METHOD
> >
> > public static Map<String,String> getSource(WebDriver driver)
> > throws InterruptedException
> >
> > {
> >
> > Map<String,String> mp = new HashMap<String,String>();
> >
> > String source = driver.getPageSource(); //BLOWS UP MEANS********
> > IT GOES TO THIS LINE AND INTERMETTINETLY IT HITS CATCH BLOCK OF
> > THE TEST,AM UNABLE TO SEE WHAT IS GOING ON HERE
> >
> > Thread.sleep(2000);
> >
> > String pageNameRegex = "s_pageName='([^']*)'";
> >
> > String chanelRegex ="s_sm.channel='([^']*)'";
> >
> > Pattern pagePattern = Pattern.compile(pageNameRegex);
> >
> > Pattern chanelPattern = Pattern.compile(chanelRegex);
> >
> > Matcher String1 = pagePattern.matcher(source);
> >
> > Matcher String2 = chanelPattern.matcher(source);
> >
> > boolean foundPagePattern = String1.find();
> >
> > boolean foundchanelPattern = String2.find();
> >
> > String searchString1 =String1.group(1);
> >
> > String searchString2 =String2.group(1);
> >
> > mp.put("s_sm.pageName", searchString1);
> >
> > mp.put("s_sm.channel", searchString2);
> >
> > return mp;
> >
> > }
> >
> > //Calling get source method
> >
> > public static String homePageSource(WebDriver driver) throws
> > InterruptedException
> >
> > {
> >
> > Map<String,String> mp = new HashMap<String,String>();
> >
> > mp=getSource(driver); // CALLING GET SOURCE METHOD HERE
> > *******************
> >
> > String sm_page= mp.get("s_sm.pageName");
> >
> > String sm_chanel= mp.get("s_sm.channel");
> >
> > if (!sm_page.equals("abcd")|| !sm_chanel.equals("tyui")
> >
> > {
> >
> > String run_log ="Home Page,";
> >
> > return run_log;
> >
> > }
> >
> > else
> >
> > {
> >
> > return "";
> >
> > }
> >
> > }
> >
> > //Test
> >
> > try
> >
> > {
> >
> > driver = getDriverByBrowserType(browserType,os);
> >
> > //From Home page submit requests for above tasks - 2 iterations
> >
> > for (String task : taskList)
> >
> > {
> >
> > driver.get(Url);
> >
> > platform = BrowserTypeandVersion.getOperatingSystem(driver);
> >
> > hostName = GetHostName.getHostName(((RemoteWebDriver)
> > driver).getSessionId());
> >
> > run_log =xxxxx.homePageSource(driver);
> >
> > REST OF THE CODE *************************
> >
> > }
> >
> > }
> >
> > catch (Exception e) { // HITS CATCH BLOCK
> >
> > driver.getCurrentUrl();
> >
> > }
> >
> > finally
> >
> > {
> >
> > driver.quit();
> >
> > }
> >
> > ==================================
> >
> >
> > On Saturday, February 16, 2013 2:02:05 PM UTC-7, darrell wrote:
> >
> > What does "BLOWS UP" mean? Does it hang for a while? How long do you
> > wait? Often if I have something which hangs for a while I'll go work
> > on something else or go for lunch. If I come back and it is still
> > hung
> > that is serious. Hopefully after 10 to 30 seconds it comes back
> > with a
> > stacktrace. Sometimes there might be multiple timeouts and I could be
> > waiting for a few minutes. I see a lot of people waiting 2 or 3
> > seconds then killing it. Waiting 2 or 3 seconds really doesn't
> > give it
> > enough time. If I want for a few minutes the stacktrace can often
> > give
> > me enough information that I save an hour trying to debug it. It also
> > helps me prevent the same mistake again in the future. In other
> > words,
> > spending a few minutes now can often save you hours over time.
> >
> > There is no context for this method. If you write a standalone method
> > that just has:
> >
> > class GoogleThread8ca6022cde58782e {
> > public static void main(String[] args) {
> > WebDriver driver = new ChromeDriver();
> > driver.get("enter your URL here");
> > Map<String,String> page =
> > GoogleThread8ca6022cde58782e.getSource(driver);
> > }
> >
> > > I am using webdriver 2.24 version.
> > >
> > > =================================
> > >
> > > public static Map<String,String> getSource(WebDriver driver) throws
> > > InterruptedException
> > > {
> > > Map<String,String> mp = new HashMap<String,String>();
> > >
> > > String source = driver.getPageSource(); //TEST BLOWS UP ON THIS
> > LINE
> > > Thread.sleep(2000);
> > > String pageNameRegex = "s_pageName='([^']*)'";
> > > String chanelRegex ="s_sm.channel='([^']*)'";
> > > Pattern pagePattern = Pattern.compile(pageNameRegex);
> > > Pattern chanelPattern = Pattern.compile(chanelRegex);
> > >
> > > Matcher String1 = pagePattern.matcher(source);
> > > Matcher String2 = chanelPattern.matcher(source);
> > >
> > > boolean foundPagePattern = String1.find();
> > > boolean foundchanelPattern = String2.find();
> > >
> > > String searchString1 =String1.group(1);
> > > String searchString2 =String2.group(1);
> > > mp.put("s_sm.pageName", searchString1);
> > > mp.put("s_sm.channel", searchString2);
> > >
> > > return mp;
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > }
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "webdriver" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to webdriver+...@googlegroups.com <javascript:>.
> > To post to this group, send email to webd...@googlegroups.com
> > <javascript:>.
> > <http://groups.google.com/group/webdriver?hl=en>.
> > For more options, visit https://groups.google.com/groups/opt_out
> > <https://groups.google.com/groups/opt_out>.
> >
> >
> >
> > --
> > Thanks & Regards
> > Krishnan Mahadevan
> >
> > "All the desirable things in life are either illegal, expensive,
> > fattening or in love with someone else!"
> > My Scribblings @ http://wakened-cognition.blogspot.com/
> > <http://wakened-cognition.blogspot.com/>
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "webdriver" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to webdriver+...@googlegroups.com <javascript:>.
> > To post to this group, send email to webd...@googlegroups.com
> > <javascript:>.
> > <http://groups.google.com/group/webdriver?hl=en>.
> > For more options, visit https://groups.google.com/groups/opt_out
> > <https://groups.google.com/groups/opt_out>.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "webdriver" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to webdriver+...@googlegroups.com <javascript:>.
> > To post to this group, send email to webd...@googlegroups.com
> > <javascript:>.
> > <http://groups.google.com/group/webdriver?hl=en>.
> > For more options, visit https://groups.google.com/groups/opt_out
> > <https://groups.google.com/groups/opt_out>.

Richard Lavoie

unread,
Feb 19, 2013, 7:38:07 PM2/19/13
to webd...@googlegroups.com
Every element on a page is tied to a locator, you might have to use xpath, css selector or even tag name, but it can be found without getting the page source.


The complexity to get to the element depends on the html layout of your page.

An example could be :

driver.findElement(By.id("someHTMLidAttributrValue").findElement(By.className("CssClassName").findElement(By.tagName("span").getText();

findElement on driver finds the element anywere on the html page while when it is from a WebElement returned by findElement, it will look under that element to find further elements.

You can then make multiple successive calls to find the right element in your HTML "tree".

Richard
has not loaded whatever you are looking for with your regex.� There is
nothing in that code to suggest that you are waiting for the page to load
correctly (which is why in my previous post I told you to look at explicit
waits).

What are you trying to do with the regex?� Pulling the entire page source
and then running regex across it seems like a slow and inaccurate way to do
things, what is your intent?



On 19/02/2013 14:37, testingzeal wrote:

Mark,

 

Here is the code for second error stack trace - No match found ..this is
intermittent error , it happens on different pages each time.

 

public static Map<String,String> getSource(WebDriver driver) throws
InterruptedException

{

Map<String,String> mp = new HashMap<String,String>();

 

String source = driver.getPageSource(); //BLOWS UP MEANS******** IT GOES TO
THIS LINE AND INTERMETTINETLY IT HITS CATCH BLOCK OF THE TEST,AM UNABLE TO
SEE WHAT IS GOING ON HERE

Thread.sleep(2000);

String pageNameRegex = "s_pageName='([^']*)'";

String chanelRegex ="s_sm.channel='([^']*)'";



 Pattern pagePattern = Pattern.compile(pageNameRegex);

Pattern chanelPattern = Pattern.compile(chanelRegex);



 

Matcher String1 �= pagePattern.matcher(source);

Matcher String2 = chanelPattern.matcher(source);

 

 

� � � � � � � � boolean foundPagePattern = String1.find();

boolean foundchanelPattern = String2.find();



 

String searchString1 =String1.group(1);

String searchString2 =String2.group(1);



 mp.put("s_sm.pageName", searchString1);

mp.put("s_sm.channel", searchString2);



 

return mp;

}

java.lang.IllegalStateException: No match found

 

� � � � at java.util.regex.Matcher.group(Matcher.java:468)

 

� � � � at
com.servicemagic.selenium.util.xxxxx.getSource(xxxxxx.java:40)

 

� � � � at
com.servicemagic.selenium.util.xxxxx.getSource(xxxxr.java:366)

 

� � � � at
com.cxcxcx.selenium.vcbvcbvbb.vvcxvcvcvcvTest.runTest(bvbvbvbvbbb.java:66)

 

� � � � 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelp
er.java:80)

 

� � � � at
org.testng.internal.Invoker.invokeMethod(Invoker.java:691)

 

� � � � at
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)

 

� � � � at
org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWi
thDataProviderMethodWorker.java:73)

 

� � � � at
org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWi
thDataProviderMethodWorker.java:14)

 

� � � � at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

 

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

 

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
va:886)

 

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9
08)

 

�Thanks!


On Monday, February 18, 2013 11:24:52 PM UTC-7, Mark Collin wrote:

If you are getting intermittent NoSuchElementExceptions you have badly
written test cases and you need to start using explicit waits:

�

http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-and-impli
cit-waits


�

As to your second error, I�m not sure.� I would need to see your code to
be able to guess.

�

From: webd...@googlegroups.com [mailto:webd...@googlegroups.com] On Behalf
Of testingzeal
Sent: 19 February 2013 01:43
To: webd...@googlegroups.com
Subject: Re: [webdriver] Issues with driver.getPageSource()

�

I am seeing 2 issues on stacktrace�

�

1. org.openqa.selenium.NoSuchElementException: The element could not be
found (WARNING: The server did not provide any stacktrace informa

Command duration or timeout: 43 milliseconds

For documentation on this error, please
<http://seleniumhq.org/exceptions/no_such_element.html> l - IT HAPPENS
INTERMITTENTLY ON DIFFERENT PAGES

�

2.Reg to driver.getpagesource() error - Here is the stack trace�

�

Again this happens on different pages each time, I think this is also timing
issue�

�

�

java.lang.IllegalStateException: No match found

� � � � at java.util.regex.Matcher.group(Matcher.java:468)

� � � � at
com.servicemagic.selenium.util.xxxxx.getSource(xxxxxx.java:40)

� � � � at
com.servicemagic.selenium.util.xxxxx.getSource(xxxxr.java:366)

� � � � at
com.cxcxcx.selenium.vcbvcbvbb.vvcxvcvcvcvTest.runTest(bvbvbvbvbbb.java:66)

� � � � 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelp
er.java:80)

� � � � at
org.testng.internal.Invoker.invokeMethod(Invoker.java:691)

� � � � at
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)

� � � � at
org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWi
thDataProviderMethodWorker.java:73)

� � � � at
org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWi
thDataProviderMethodWorker.java:14)

� � � � at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
va:886)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9
08)

�

�

�

Thanks!

�

�

�

On Mon, Feb 18, 2013 at 2:47 PM, testingzeal <jsel...@gmail.com> wrote:

I got this�NoSuchElementException - Below is the complete stack trace,
This happens on different pages each time.Actually all the elements are
there.Is there a way to get around this?�

�

�

=========================================

org.openqa.selenium.NoSuchElementException: The element could not be found
(WARNING: The server did not provide any stacktrace informa

Command duration or timeout: 43 milliseconds

For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19
17:28:14'

System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.1',
java.version: '1.6.0'

Driver info: driver.version: EventFiringWebDriver

Session ID: 64e2ad4e0e915c49239e7e34945cdb1a

Command duration or timeout: 359 milliseconds

For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19
15:28:49'

System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2',
java.version: '1.6.0_26'

Driver info: driver.version: RemoteWebDriver

Session ID: 1361212119582

� � � � at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

� � � � at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces
sorImpl.java:39)

� � � � at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc
torAccessorImpl.java:27)

� � � � at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)

� � � � at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:18
8)

� � � � at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.j
ava:145)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:
242)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWe
bDriver.java:319)

� � � � at
org.openqa.selenium.By$ByCssSelector.findElement(By.java:405)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:
234)

� � � � at
com.servicemagic.selenium.util.OmnitureHelper.validateManualSR(OmnitureHelpe
r.java:1353)

� � � � at
com.servicemagic.selenium.util.OmnitureHelper.submitSR(OmnitureHelper.java:1
005)

� � � � at
com.homeadvisor.selenium.omnituresrpaths.OmnitureMMRSRPathTest.runTest(Omnit
ureMMRSRPathTest.java:93)

� � � � 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelp
er.java:80)

� � � � at
org.testng.internal.Invoker.invokeMethod(Invoker.java:691)

� � � � at
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)

� � � � at
org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWi
thDataProviderMethodWorker.java:73)

� � � � at
org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWi
thDataProviderMethodWorker.java:14)

� � � � at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
va:886)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9
08)

� � � � at java.lang.Thread.run(Thread.java:662)

Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has
been taken

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19
15:28:49'

System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2',
java.version: '1.6.0_26'

Driver info: driver.version: RemoteWebDriver

� � � � at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.j
ava:125)

� � � � ... 22 more

Caused by: org.openqa.selenium.NoSuchElementException: The element could not
be found (WARNING: The server did not provide any stacktr

�

Command duration or timeout: 43 milliseconds

For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19
17:28:14'

System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.1',
java.version: '1.6.0'

Driver info: driver.version: EventFiringWebDriver

Session ID: 64e2ad4e0e915c49239e7e34945cdb1a

For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19
15:28:49'

System info: os.name: 'Windows 2003', os.arch: 'x86', os.version: '5.2',
java.version: '1.6.0_26'

Driver info: driver.version: EventFiringWebDriver

� � � � at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

� � � � at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces
sorImpl.java:39)

� � � � at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc
torAccessorImpl.java:27)

� � � � at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)

� � � � at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:18
8)

� � � � at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.j
ava:145)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:
242)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWe
bDriver.java:319)

� � � � at
org.openqa.selenium.By$ByCssSelector.findElement(By.java:406)

� � � � at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:
234)

� � � � at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown
Source)

� � � � at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)

� � � � at java.lang.reflect.Method.invoke(Method.java:597)

� � � � at
org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiring
WebDriver.java:101)

� � � � at $Proxy1.findElement(Unknown Source)

� � � � at
org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFir
ingWebDriver.java:180)

� � � � at
org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:
47)

� � � � at
org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:
1)

� � � � at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

� � � � at java.util.concurrent.FutureTask.run(FutureTask.java:138)

� � � � at
org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:1
50)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja
va:885)

� � � � at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9
07)

� � � � at java.lang.Thread.run(Thread.java:619)

==================


On Saturday, February 16, 2013 8:11:36 PM UTC-7, testingzeal wrote:

Thanks Krishnan! And of course i am unable to reproduce the error
printstacktrace(),but i'll run it tomorrow and monday and am sure it will
reappear again.I'll keep you posted.

On Saturday, February 16, 2013 7:24:50 PM UTC-7, Krishnan wrote:

Either do a e.printStackTrace() or get rid of the try catch and pls share
the stacktrace. You seem to be gobbling up the exception

On Sunday, February 17, 2013, testingzeal wrote:

Sorry for not giving clear details ,Below are the complete details of the
problem.

============================================================

I was have chrome driver version of 22.0.1203.0b and test is using Chrome
Browser 24.0.1312.57... not sure if this is the problem

�

Now I upgraded my chrome driver to 26.0.1383.0

�

�

BLOWS UP MEANS******** It goes to this line (String source =
driver.getPageSource(); ) AND INTERMETTINETLY IT HITS CATCH BLOCK OF THE
TEST Immediately,am unable to see what's going on here.

�

NOTE -++++++++++++++++++++++++++++++++++++++

I am running tests as a suite not sure if tests are competing with each
other as all the tests use the getSourcemethod(),every time it blows up on
different page/different test.Really confused what to do here as same issue
happens on diff pages/tests every time.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

�

Below is the structure of the test.

�

//METHOD�

�

public static Map<String,String> getSource(WebDriver driver) throws
InterruptedException

{

Map<String,String> mp = new HashMap<String,String>();

�

String source = driver.getPageSource(); //BLOWS UP MEANS******** IT GOES TO
THIS LINE AND INTERMETTINETLY IT HITS CATCH BLOCK OF THE TEST,AM UNABLE TO
SEE WHAT IS GOING ON HERE

Thread.sleep(2000);

String pageNameRegex = "s_pageName='([^']*)'";

String chanelRegex ="s_sm.channel='([^']*)'";

Pattern pagePattern = Pattern.compile(pageNameRegex);

Pattern chanelPattern = Pattern.compile(chanelRegex);

�

Matcher String1 �= pagePattern.matcher(source);

Matcher String2 = chanelPattern.matcher(source);

�

�

� � � � � � � � boolean foundPagePattern = String1.find();

boolean foundchanelPattern = String2.find();

�

String searchString1 =String1.group(1);

String searchString2 =String2.group(1);

mp.put("s_sm.pageName", searchString1);

mp.put("s_sm.channel", searchString2);

�

return mp;

}

�

�

//Calling get source method�

�

public static String homePageSource(WebDriver driver) throws
InterruptedException

{

Map<String,String> mp = new HashMap<String,String>();

mp=getSource(driver); // CALLING GET SOURCE METHOD HERE *******************

�

String sm_page= mp.get("s_sm.pageName");

String sm_chanel= mp.get("s_sm.channel");

�

if (!sm_page.equals("abcd")|| !sm_chanel.equals("tyui")

{

String run_log ="Home Page,";

return run_log;

}

else

{

return "";

�

}

}

�

�

//Test

�

try

� � � � � � {

� � � � � � � � � driver =
getDriverByBrowserType(browserType,os);

� � � � � � � � � //From Home page submit requests for
above tasks - 2 iterations

� � � � � � � � � for (String task : taskList) �

� � � � � � � � � { �

� � � � � � � � � � � � �driver.get(Url);

� � � � � � � � � � � � platform =
BrowserTypeandVersion.getOperatingSystem(driver);

� � � � � � � � � � � � hostName =
GetHostName.getHostName(((RemoteWebDriver) driver).getSessionId());

� � � � � � � � � � � � run_log
=xxxxx.homePageSource(driver);

� � � � � � � � � � � ��

� � � � � � � � � � � �REST OF THE CODE
*************************

� � � � � � � � � � � �}

�

� � � � � � }

� � � � � � catch (Exception e) { // HITS CATCH BLOCK�

� � � � � � � � � driver.getCurrentUrl();

� � � � � � � � ��

� � � � � � }

� � � � � � finally

� � � � � � {

� � � � � � � � � driver.quit();

� � � � � � }

�

==================================


On Saturday, February 16, 2013 2:02:05 PM UTC-7, darrell wrote:

What does "BLOWS UP" mean? Does it hang for a while? How long do you
wait? Often if I have something which hangs for a while I'll go work
on something else or go for lunch. If I come back and it is still hung
that is serious. Hopefully after 10 to 30 seconds it comes back with a
stacktrace. Sometimes there might be multiple timeouts and I could be
waiting for a few minutes. I see a lot of people waiting 2 or 3
seconds then killing it. Waiting 2 or 3 seconds really doesn't give it
enough time. If I want for a few minutes the stacktrace can often give
me enough information that I save an hour trying to debug it. It also
helps me prevent the same mistake again in the future. In other words,
spending a few minutes now can often save you hours over time.

There is no context for this method. If you write a standalone method
that just has:

class GoogleThread8ca6022cde58782e {
� � public static void main(String[] args) {
� � � � WebDriver driver = new ChromeDriver();
� � � � driver.get("enter your URL here");
� � � � Map<String,String> page =
GoogleThread8ca6022cde58782e.getSource(driver);
� � }

� � // enter your getSource method here
}

Add the appropriate Selenium libraries to the project, add the
appropriate import statements to this class, get it to compile and run
it as a Java application.

If this still "BLOWS UP" then make sure you are adding all the right
libraries to your project. Make sure that the first ChromeDriver.exe
it finds in your %PATH% is the correct ChromeDriver.exe (remember, if
you copied version 17 into C:\Windows\System32 it will find that
version before it finds the version you want). If this application
works (and I suspect it will) then try adding a little more and a
little more until it "BLOWS UP". Hopefully, when you add in that last
thing which makes it "BLOWS UP" it will be obvious why it isn't work
and what you need to do to fix it.

Darrell


On Feb 15, 9:50�pm, jyo rani <jselen...@gmail.com> wrote:
> I have a test that opens a browser and clicks on a link and validate
source
> code of the page(during debugging i see page is open and landed on correct

> page)but intermittently fails on driver.getPageSource(),that's the reason
I
> introduced sleep time so that driver can get page source ,but it didn't
> work either , not sure how to resolve this. Is there a better way to do
> this?
>
> I am using webdriver 2.24 �version.
>
> =================================
>
> public static Map<String,String> getSource(WebDriver driver) throws
> InterruptedException
> {
> Map<String,String> mp = new HashMap<String,String>();
>
> String source = driver.getPageSource(); //TEST BLOWS UP ON THIS LINE
> Thread.sleep(2000);
> String pageNameRegex = "s_pageName='([^']*)'";
> String chanelRegex ="s_sm.channel='([^']*)'";
> �Pattern pagePattern = Pattern.compile(pageNameRegex);
> Pattern chanelPattern = Pattern.compile(chanelRegex);
>
> Matcher String1 �= pagePattern.matcher(source);
> Matcher String2 = chanelPattern.matcher(source);
>
> � � � � � � � � boolean foundPagePattern = String1.find();

> boolean foundchanelPattern = String2.find();
>
> String searchString1 =String1.group(1);
> String searchString2 =String2.group(1);
> �mp.put("s_sm.pageName", searchString1);
> mp.put("s_sm.channel", searchString2);
>
> return mp;
>
>
>
>
>
>
>
> }

--
You received this message because you are subscribed to the Google Groups
"webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
�
�



--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening
or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to the Google Groups
"webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
�
�

�

--
You received this message because you are subscribed to the Google Groups
"webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
�
�

--
You received this message because you are subscribed to the Google Groups
"webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to webdriver+...@googlegroups.com <javascript:> .
To post to this group, send email to webd...@googlegroups.com <javascript:>

--

testingzeal

unread,
Feb 19, 2013, 9:28:25 PM2/19/13
to webd...@googlegroups.com
It is tied in Java script and there are multiple javascript calls on that page. Below is my html code

String i am looking exists only in the page source and it is not tied to specific locator.

Do you mean this is more accurate way?

driver.getPageSource().contains("your text");
not sure how to tie pagesource() and gettext()....

<script language="JavaScript" type="text/javascript">

  s_1.pageName='Guest';

  s_2.channel='General';

  s_3.server='qa';

  s_4.eVar11='xxxx';

  s_5.eVar76='xxxx';

  s_6.list1='3767';

  s_7.list2='Jxxxx';

  s_sm.eVar39='210';

  s_sm.prop26='';

</script>

Richard Lavoie

unread,
Feb 19, 2013, 10:16:28 PM2/19/13
to webd...@googlegroups.com
If you wanna retrieve information from javascript, you can do that with the JavascriptExecutor interface.

String channel = (String) ((JavascriptExecutor)driver).executeScript("return s_2.channel;");

Mark Collin

unread,
Feb 20, 2013, 1:45:59 AM2/20/13
to webd...@googlegroups.com
The page source will be the currently computed page source when the
getPageSource request is sent if I remember correctly (may have to double
check that).

-----Original Message-----
From: webd...@googlegroups.com [mailto:webd...@googlegroups.com] On
> > at
> >
> > org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorH
> > andler.java:145)
> >
> > at
> >
> > org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.j
> > ava:472)
> >
> > at
> >
> > org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriv
> > er.java:242)
> >
> > at
> >
> > org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(
> > RemoteWebDriver.java:319)
> >
> > at org.openqa.selenium.By
> >
> > <http://org.openqa.selenium.By>$ByCssSelector.findElement(By.java:40
> > 5)
> >
> > at
> >
> > org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriv
> > er.java:234)
> >
> > at
> >
> > com.servicemagic.selenium.util.OmnitureHelper.validateManualSR(Omnit
> > ureHelper.java:1353)
> >
> > at
> >
> > com.servicemagic.selenium.util.OmnitureHelper.submitSR(OmnitureHelpe
> > r.java:1005)
> >
> > at
> >
> > com.homeadvisor.selenium.omnituresrpaths.OmnitureMMRSRPathTest.runTe
> > st(OmnitureMMRSRPathTest.java:93)
> >
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> >
> > at
> >
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl
> > .java:39)
> >
> > at
> >
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
> > ssorImpl.java:25)
> >
> > at java.lang.reflect.Method.invoke(Method.java:597)
> >
> > at
> >
> > org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvoca
> > tionHelper.java:80)
> >
> > at
> > org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
> >
> > at
> > org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
> >
> > at
> >
> > org.testng.internal.TestMethodWithDataProviderMethodWorker.call(Test
> > MethodWithDataProviderMethodWorker.java:73)
> >
> > at
> >
> > org.testng.internal.TestMethodWithDataProviderMethodWorker.call(Test
> > MethodWithDataProviderMethodWorker.java:14)
> >
> > at
> >
> > java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> >
> > at
> > java.util.concurrent.FutureTask.run(FutureTask.java:138)
> >
> > at
> >
> > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExe
> > cutor.java:886)
> >
> > at
> >
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecuto
> > ConstructorAccessorImpl.java:27)
> >
> > at
> > java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> >
> > at
> >
> > org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler
> > .java:188)
> >
> > at
> >
> > org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorH
> > andler.java:145)
> >
> > at
> >
> > org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.j
> > ava:472)
> >
> > at
> >
> > org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriv
> > er.java:242)
> >
> > at
> >
> > org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(
> > RemoteWebDriver.java:319)
> >
> > at org.openqa.selenium.By
> >
> > <http://org.openqa.selenium.By>$ByCssSelector.findElement(By.java:40
> > 6)
> >
> > at
> >
> > org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriv
> > er.java:234)
> >
> > at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown
> > Source)
> >
> > at
> >
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
> > ssorImpl.java:25)
> >
> > at java.lang.reflect.Method.invoke(Method.java:597)
> >
> > at
> >
> > org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(Eve
> > ntFiringWebDriver.java:101)
> >
> > at $Proxy1.findElement(Unknown Source)
> >
> > at
> >
> > org.openqa.selenium.support.events.EventFiringWebDriver.findElement(
> > EventFiringWebDriver.java:180)
> >
> > at
> >
> > org.openqa.selenium.remote.server.handler.FindElement.call(FindEleme
> > nt.java:47)
> >
> > at
> >
> > org.openqa.selenium.remote.server.handler.FindElement.call(FindEleme
> > nt.java:1)
> >
> > at
> >
> > java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> >
> > at
> > java.util.concurrent.FutureTask.run(FutureTask.java:138)
> >
> > at
> >
> > org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSessio
> > n.java:150)
> >
> > at
> >
> > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExe
> > cutor.java:885)
> >
> > at
> >
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecuto
Reply all
Reply to author
Forward
0 new messages