1

I am trying to open selenium on the same browser which is not opened using webdriver. I used python built-in library called "webbrowser", and it open a url on the same browser which is my default when I used .get command it returned me a instance.
I wonder if I can use this instance to use functionalities of selenium webdriver.
Following will get you some idea I am trying to do.

Instance created using web browser library

import webbrowser

webbrowser.open('https://www.example.com')

webrowser.get()

Output

<webbrowser.WindowsDefault at 0x221540bb730>

What I want is

from selenium import webdriver

webdriver.Remote() #or any way in which i give input above instance and in term get all options to controll browser.

I think there should be any way to tackle with this type of problem as it will gains us the access of the default browser and we can perform our automation task without any type of restriction from any domain.

If any one has any query, feel free to ask me.

Ali Kamal
  • 33
  • 1
  • 7
  • 1
    Does this answer your question? [Can Selenium interact with an existing browser session?](https://stackoverflow.com/questions/8344776/can-selenium-interact-with-an-existing-browser-session) – JeffC May 21 '21 at 18:09
  • 1
    basically you need the sessionID. To get the sessionID you need to have launched the browser in dev mode. You can then get the ID and use it in your webdriver call. (I believe this will cause an extra browser to launch, which you have to abandon...) – pcalkins May 21 '21 at 21:35
  • @JeffC yeah that question is based on java and I have no idea with java language uptil now. I wonder if there is any solution to this problem in python. I have just described my one way that anyone can get an idea for this in python – Ali Kamal May 22 '21 at 04:37
  • If you read the link from that post, he's creating a Selenium driver instance, getting the SessionId, and then starting a new driver from that SessionId. I'm not sure why that would be useful to anyone because you already have the first driver instance. The summary of the answer is that it's not possible/supported... for any language. – JeffC May 22 '21 at 05:00
  • Actually my question is bit different, In my case I haven't created any selenium instance before and want to use selenium on a browser which is opened by default by my computer. I want this because some sites uses some restriction to avoid selenium web drivers but if I use my default browser I get no restrictions. I am looking for a method which can use that default browser to avoid restrictions. – Ali Kamal May 22 '21 at 05:21

0 Answers0