0

I'm trying to write a test for a pair of sites taking part in the online support system: one is for Agent, the second is for the Visitor.

Initially, the Visitor opens the support tab on his site and the Agent gets the call on his side and picks it up. Both sides get the text chat only at this moment. After that, the Agent wants to escalate the chat-call to Audio-Video level and presses a special button for that. An additional widget opens containing the IFRAME element with INVITE button. Agent presses the INVITE button. After that the Agent has to press the Send button in the textual chat (that is on the main page content, not in the IFRAME) to send the invitation for the agent to join the Audio-Video chat.

These are the steps that I want to automate.

Everything is working until the .switch_to_default_content(). After that, the browser seems to lose the DOM and does not find neither elements on the main page nor inside the IFRAME.

Behavior is the same for local WebDriver and for WebDriver.Remote grid, for Chrome latest and Firefox latest, on Windows 10 and on Mac OS X 10.11.6 regardless of Capabilities combination.

Below is the code in Pytnon:

#Starting the Agent browser
options = webdriver.ChromeOptions()
options.add_argument("--disable-notifications")
agent_browser = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=options.to_capabilities())

<...>

#Starting the Visitor browser
visitor_browser = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=DesiredCapabilities.CHROME)

<...>

# Finding the IFRAME
agent_LPVE_iframe = WebDriverWait(agent_browser, 30).until(EC.presence_of_element_located((By.XPATH, "//iframe[contains(@class, 'lpview_table_items_placeholder')]")))

# Switching to IFRAME   
agent_browser.switch_to_frame(agent_LPVE_iframe)

<...>

# Switching to default contents
#agent_browser.switch_to_default_content()
agent_browser.switch_to.default_content()

After this, the WebDriver becomes unable to find any element in both main page DOM and inside the IFRAME even if it gets switched back to IFRAME.

Why it happens and how do I make it work correctly?

I am using:
- Python 3.6.0 x32
- selenium-server-standalone-3.3.1.jar
- ChromeDriver 2.28 Win32
- GeckoDriver 0.14.0 x64

Tell me if you need any additional information.

  • Something similar happened to me once. The reason was I reloading the url before the calling that method. – ngub05 Apr 04 '17 at 14:45
  • Search stackoverflow. There are plenty of Q&A's about iframes, Selenium, and python. [This](https://stackoverflow.com/questions/18924146/selenium-and-iframe-in-html) or [this](https://stackoverflow.com/questions/28723143/function-for-switching-frames-in-python-selenium) for example. It is better to explicitly switch between iframes. – MikeJRamsey56 Apr 04 '17 at 22:00
  • Thanks. I am switching between one iframe and the default content, not between iframes. – Pavel Ivanov Apr 05 '17 at 07:33

0 Answers0