getPageSource showing code that is not shown when selecting View Page Source in browser.

197 views
Skip to first unread message

kathyj

unread,
Jul 25, 2013, 2:51:41 PM7/25/13
to seleniu...@googlegroups.com
I posted something similar a couple of weeks ago, but after re-reading it, I'm not sure if I was clear.  And after looking at the document snippet that comes with the method, it says:

 "Get the source of the last loaded page. If the page has been modified after loading (for example, by Javascript) there is no guarantee that the returned text is that of the modified page. Please consult the documentation of the particular driver being used to determine whether the returned text reflects the current state of the page or the text last sent by the web server. The page source returned is a representation of the underlying DOM: do not expect it to be formatted or escaped in the same way as the response sent from the web server. Think of it as an artist's impression."

I'm not sure what is meant by the driver.  I'm using the WebDriver function.  When I call the getPageSource, it returns a string of the "supposed" text on the ViewPageSource.  I'm looking for a string that has been removed to ensure it doesn't show up.  When I do this manually, the string is definitely not there, but when looking at the text retrieved by getPageSource, it's still finding the string on some pages.  Has anyone else experienced anything similar with this method?  If so, is there a workaround I could try?  My code is pretty basic:
     
      sPageSource = driver.getPageSource();
         if( sPageSource.contains( sTag)) {
            bFound = true;
         }

Any help or suggestions would be greatly appreciated. 


Karthik Kulkarni

unread,
Jul 26, 2013, 12:04:21 AM7/26/13
to seleniu...@googlegroups.com

Kathy

When the say driver they imply that it works according to the underlying browser. In the meantime the tag which you are looking gets into n the page source after any event

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2a0ef3cb-e3d6-4b84-bcb7-fcf1493ec328%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ping Pong

unread,
Nov 11, 2014, 8:20:31 AM11/11/14
to seleniu...@googlegroups.com
Is there a way to ask selenium to re-load\re-collect page's source, for example: After ajax selenium might still hold the previous page source and i know it takes 10 seconds for ajax to return, i need to know how to ask selenium to update it's source?

Krishnan Mahadevan

unread,
Nov 11, 2014, 8:53:18 PM11/11/14
to Selenium Users

Karthik

Assuming you have a mechanism to know when the ajax call has completed doesn't getPageSource  () not give you the updated page source ?

You can cause the page to reload by perhaps using javascript or by navigating back and forth but I think that may re trigger your ajax call once again no ?

Reply all
Reply to author
Forward
0 new messages