Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97771

How to pass python data back to the calling script about a browser window left open when the called script closes

$
0
0

I am trying to find the best method to pass data from python script2.py back to the calling script (script1.py). I am using Python 3 on Linux.

Script1 calls script2.py which then uses Selenium to open a browser window and do something things. When script2 ends, the browser remains open and script1 continues. What I want is to then be able to work on the browser window that was opened in script2, from within script1.

So far I have failed to find a suitable way to pass the information about the open browser window from script2 back to script1. I believe part of the issue is because when script2 is called, script1 waits until it has closed before continuing on, so there is no way to grab the variables open in script2. I do not want to change this aspect either.

in script1.py the below code calls script2 like this:

cmd = ['python3', '/home/admin/Desktop/Python_stuff/live-scripts/script2.py']
        subprocess.Popen(cmd).wait() # Python will now wait for script to end before continuing

in script2 the below code opens the browser initially (which currently stays open after script2 closes) like this:

driver.get(targetURL)

I have looked at Pickle but could not get it to work how I wanted and will probably next try to use import JSON. But I wondered if I am missing a more simple method to achieve what I want here.


Viewing all articles
Browse latest Browse all 97771

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>