When dealing with Synthetic monitoring for services that have a step where either a new window or tab is involved after an action is taken the monitor fails to record the resulting new page.
Would be nice to have the recorder be able to handle this type of scenario since this is possible with Selenium which the recorder is based on... Here is an example I found online of dealing with this cenario:
# filename: new_window.py import unittest from selenium import webdriver class Windows(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() def tearDown(self): self.driver.quit() def test_example_2(self): driver = self.driver driver.get('the-internet.herokuapp.com/windows') first_window = driver.window_handles[] driver.find_element_by_css_selector('.example a').click() all_windows = driver.window_handles for window in all_windows: if window != first_window: new_window = window driver.switch_to_window(first_window) assert driver.title != "New Window", "title should not be New Window" driver.switch_to_window(new_window) assert driver.title == "New Window", "title should be New Window" if __name__ == "__main__": unittest.main()
Like (1)
Reply
Replies (0)