Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

How to get only the current window html source using Selenium web driver #4989

Closed
lukeis opened this issue Mar 4, 2016 · 7 comments
Closed

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 4989

Server using
-------------------
selenium-server-standalone-2.25.0.jar

Os: Windows 7

Firefox: 10.0.11

The webdriver API "getPageSource()" retrieves the source of all closed windows HTML
souce. Is there a way to get only current window or focussed windows HTML page source.

Reported by kashivillage143 on 2013-01-08 09:02:59

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

getPageSource should return the HTML of the currently focused window.  It will be a
live snapshot, not the raw source returned from the server.

If this is not the behavior you are seeing, please provide a reproducible test case.

Reported by jmleyba on 2013-01-08 15:22:08

  • Status changed: NeedsClarification
  • Labels added: Component-WebDriver, Browser-Firefox
  • Labels removed: Status-Untriaged

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

For example , in attached snapshot i will click "issues" tab and then "project home"
tab. If i try to take page source i will get "project home" and "issues" tab page source.


Is there a way to get only focused tab i mean "project home" page source.

Reported by kashivillage143 on 2013-01-08 16:53:52


- _Attachment: sample.png
![sample.png](https://storage.googleapis.com/google-code-attachments/selenium/issue-4989/comment-2/sample.png)_

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Please tell us exactly what page are you on (what's in the address bar), and what wrong
parts (or text) do you see in the page source?

Reported by barancev on 2013-01-09 16:32:41

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

He probably just doesn't realize that the content is being updated by an ajax call that
injects the new content into the DOM, which is why he gets the page source for all
tabs he has visited (this is a theory to his problem anyway).

In order to get just the source of the just the section, first identify the element,
and then use javascript to pull the html:

webdriver.executeScript("var f = document.createElement('div').appendChild(arguments[0].cloneNode(true));
return f.parentNode.innerHTML", element);



Reported by x.bgoad@reverbnation.com on 2013-01-15 21:16:22

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Thanks for the response...I will try with above logic and get back if there any queries

Reported by kashivillage143 on 2013-01-18 16:34:02

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Closing the issue. Feel free to ask for reopening if it is still actual.

Reported by barancev on 2013-01-20 18:38:57

  • Status changed: WorkingAsIntended

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:16:32

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant