1
I’m making a code to access a template page of my institution.
Objective: In the first guide, I open the digital book; In the second guide, I open the template.
However, I have to do the feedback in order to enter two different links to finally be able to enter a certain discipline.
My attempt was to do the following: (Example with overflow)
from time import sleep
from selenium import webdriver
driver = webdriver.Firefox()
btlivro = driver.get("https://answall.com") # Primeira guia
sleep(3)
driver.execute_script("window.open('/questions')") # Segunda Guia
sleep(3)
btdisciplina1 = driver.get("/questions/ask")
But what really happens is that the url inside btdisciplina1
is accessed inside the first tab, not the second tab I just opened.
In short: How can I do to the url inside btdisciplina1
be accessed in the second tab?
You can control the access of tabs as it was through the keyboard, Ctrl + t (new tab) Ctrl +1 access first tab Ctrl + 2 access the second tab opened. send_keys. Selenium has this control using the following syntax Keys.CONTROL + ’t' :new tab... access the first tab Keys.CONTROL + '1) using the import syntax from Selenium.webdriver.common.Keys import Keys send_keys(Keys.CONTROL + '1'
– stack.cardoso
For some reason, this is not working in my program.
body = driver.find_element_by_tag_name("body")
jumps linebody.send_keys(Keys.CONTROL + 't')
)– Halloween726