I am using Firefox Webdriver in Python 2.7 for Windows to simulate opening ( Ctrl+ t) and closing ( Ctrl+ w) of a new tab
Here is my code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get('https://www.google.com')
main_window = browser.current_window_handle
browser.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
browser.get('https://www.yahoo.com')
browser.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 'w')
How to achieve the same thing on a Mac? Based on this comment , it should be used browser.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 't')to open a new tab, but I donβt have a Mac to check it and what is equivalent Ctrl-w?
Thank!
source
share