如何切换到新打开的窗口?
我尝试了window name=,但我不知道如何获取窗口名称或自动切换到新打开的窗口,因为上一个窗口已自动关闭
try: #after first login, popup disapears
wait = WebDriverWait(driver, 100)
wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="chakra-modal--header-1"]/button/svg/path')))
driver.find_element(by = By.XPATH, value = '//*[@id="chakra-modal--header-1"]/button/svg/path').click() #exit pop-up
except:
pass
#once in page
#HERE I GOT THE ERROR
wait = WebDriverWait(driver, 100)
wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="root"]/div[1]/div[1]/p')))
elem = driver.find_element(by = By.XPATH, value = '//*[@id="root"]/div[1]/div[1]/p') #find balance element
2条答案
按热度按时间yc0p9oo01#
您可以找到所有打开的窗口/选项卡:
你可以打开的窗口/选项卡的数量:
要切换:
ldxq2e6h2#
驱动程序。switch_to.window(window_handle ID)工作正常,谢谢