0

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?

3
  • It seems that there are different ways in IDE and WebDriver to identify objects... If you want to know for sure how to select window: click right button on required window and click on "explore element's code" or something like this (depends on browser) to get html source code. Copy it and update your question with this part of code, then I could tell you correct selector to use in Python script Commented Nov 30, 2015 at 20:47
  • Painfully easy method to switch between windows (2 ideally) gist.github.com/ab9-er/08c3ce7d2d5cdfa94bc7. Tell me if this works for you. Commented Dec 1, 2015 at 10:03
  • Did it work for you? Commented Dec 8, 2015 at 13:06

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.