mercredi 3 mars 2021

Whenever I click on Button It should open a new tab and run the Selenium Script. Python, Selenium and Tkinter. It doens't work after first iteration

I have created a button where I used a command that will execute the function. btn = Button(top, text="Create Ticket", command=lambda:[run1()])

def run1(): 
  driver.execute_script("window.open('');")    
  driver.switch_to.window(driver.window_handles[1])
  driver.get('http://www.google.com')

Now, whenever I click on btn It will just open a new window without focus on the new tab and not running the later script which is driver.get('http://www.google.com').

My motive is whenever (n) I click on btn it should open a new tab with focus on it and running the later selenium script on that new tab.

**Note : driver.execute_script("window.open('https://ift.tt/3uS2TXh) I have tried this as well, It opens in new tab but doesn't have focus on it. **

Any help is much appreciated.

Aucun commentaire:

Enregistrer un commentaire