Web Page Already Open (in Source Format); Just Need To Read That Text, Using Selenium
Solution 1:
If you are asking if you can attach to an already open browser, then I believe the answer is "No".
Solution 2:
You can get the Source of the page directly with Selenium: WebDriver.getPageSource().
But if you use view-source:url
the browser will present you a html-page including the formatted source. Firefox e.g. is wrapping each line in a <span id="lineX"></span>
. Instead of parsing this just use getPageSource
without view-source
.
Please read carefully the documentation of getPageSource
:
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.
Solution 3:
This is what I used to do :
- Ask selenium to open a browser
- Show a popup/message window to pause execution
- Open the URL in the browser and perform all the related operations manually
- When I'm done (i.e. on the target page), I click OK on the popup and then the code resumes, extracting/doing the tasks we want on the target page opened currently in the browser.
Post a Comment for "Web Page Already Open (in Source Format); Just Need To Read That Text, Using Selenium"