简体   繁体   中英

Convert Selenium IDE Syntax to Python Webdriver

In Selenium IDE it tells me to use the command

selectWindow

and that the target is:

name={"id":"a52b0dc5-b1f5-2020-01db-139f01c0204a","containerVersion":"7-GA","webContextPath":"/345","preferenceLocation":"https:/url/345/prefs","relayUrl":"https:/url/o345/is/eas/rpc_relay.uncompressed.html","lang":"en_US","currentTheme":{"themeName":"a_default","themeContrast":"standard","themeFontSize":12},"345":true,"layout":"desktop","url":"/brvt","guid":"260f0022-66de-a78b-3ce8-8de63a3bdbec","version":1,"locked":false}

How do I convert this in python using driver.switch_to_window ?

I have tried:

driver.switch_to_window(driver.find_element_by_name("{"id":"a52b0dc5-b1f5-2020-01db-139f01c0204a","containerVersion":"7-GA","webContextPath":"/345","preferenceLocation":"https:/url/345/prefs","relayUrl":"https:/url/o345/is/eas/rpc_relay.uncompressed.html","lang":"en_US","currentTheme":{"themeName":"a_default","themeContrast":"standard","themeFontSize":12},"345":true,"layout":"desktop","url":"/brvt","guid":"260f0022-66de-a78b-3ce8-8de63a3bdbec","version":1,"locked":false}"))

Suggestions?

A painfully easy method to switch between windows (2 ideally) gist.github.com/ab9-er/08c3ce7d2d5cdfa94bc7 .

def change_window(browser):
    """
    Simple window switcher without the need of playing with ids.
    @param browser: Current browser instance
    """
    curr = browser.current_window_handle
    all_handles = browser.window_handles
    for handle in list(set([curr]) - set(all_handles)):
        return browser.switch_to_window(handle)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM