Search code examples
seleniumweb-scrapingkantu

How can selenium automatically capture the value from an existing web browser page and use that value in the new session?


The issue here is I'm trying to scrape a value which is displayed in a current webpage that I'm in and selenium has to capture that value and do certain operations accordingly. The value is dynamic and that webpage can not be reopened through selenium.


Solution

  • The websites can only authenticate the browsers using Cookies which are basically special HTTP Headers so if the browser sends the cookie the websites expects - the website "recognizes" the user and vice versa.

    If you want to continue where you left off with Selenium you need to export cookies somehow from the existing session and add them to the browser which is driven by Selenium, there are several API methods which allow cookie manipulation, refer your Selenium client library documentation for specific instructions.