我目前正在使用chrome(selenium)为我实现自动化。由于某些原因,我无法让selenium打开另一个网页
def gotoInventory():
#WebDriverWait(driver,5)
inventoryPS = driver.switch_to.window(driver.window_handles[1])
inventoryPS
openInventoryTab = driver.execute_script("window.open('https://sellercentral.amazon.com/inventoryplanning/dashboard','new window')")
openInventoryTab
def loginProton():
#Need to create a new tab to open proton mail
ActionChains(driver).key_down(Keys.CONTROL).send_keys('t').key_up(Keys.CONTROL).perform()
#above code did not work
#also tried browser.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
openProtonTab = driver.execute_script("window.open('https://mail.protonmail.com/login','new window')")
openProtonTab
由于某些原因,selenium总是在inventory选项卡上打开网页,这不是我想要的。protonMail必须在其自己的选项卡上打开,而不是在库存选项卡上打开
任何帮助都会被极大地吸引
出现此问题的原因是在两种情况下使用相同的窗口名,即“新窗口”。您可以尝试在库存和质子案例中使用不同的窗口名称。另请注意,window.open会创建一个浏览器窗口
相关问题 更多 >
编程相关推荐