Take an example of Facebook
I have the main page in the driver object
I have the url of the element I want to access(comments of first post)
1 how can I open it another tab
2 will this new tab be saved in some sort of object just like driver(so that I can perform actions on it)
I have reached the solution.
For getting button of the desired link we can do this:
button = driver.wait.until(EC.visibility_of_element_located((By.NAME,'login' )))
when you have the button that you want to click then do this
storyButton.send_keys(Keys.CONTROL + Keys.RETURN)
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.TAB)
for transferring control to the second tab we can do this
tabs = driver.window_handles #creates a list of tabs
driver.switch_to_window(tabs[1]) #switches driver control to the second tab
now every thing will be done in the second tab until controls are shifted back to the first tab
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.