我寫了示例代碼,但它不工作。還觀察到,2個選項卡只有1個窗口句柄。如何再次切換到父母標籤?使用硒webdriver切換回父母標籤
driver = webdriver.Firefox()
driver.set_page_load_timeout(60)
driver.implicitly_wait(15)
driver.get("https://www.google.co.in")
oldtab = driver.current_window_handle
print oldtab
print driver.title
body = driver.find_element_by_tag_name("body")
print 'new tab opened'
driver.get("http://gmail.com/")
print driver.title
print 'back to old tab'
driver.switch_to_window(oldtab)
print driver.title
for handle in driver.window_handles:
print "Handle = ",handle
This print'Google Gmail Gmail Gmail''但它應該是'Google Gmail Google Gmail'! – SIslam