|
6 | 6 |
|
7 | 7 | from selenium import webdriver
|
8 | 8 | from selenium.webdriver.chrome.options import Options
|
| 9 | +from selenium.webdriver.common.action_chains import ActionChains |
| 10 | +from selenium.webdriver.common.keys import Keys |
| 11 | + |
9 | 12 | chrome_options = Options()
|
10 | 13 | chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))
|
11 | 14 |
|
|
21 | 24 | driver.switch_to_window(driver.window_handles[-1])
|
22 | 25 | output = driver.find_element_by_id('output')
|
23 | 26 | assert(output.get_attribute('value') == '["inject-js-start","body-start","inject-js-end","onload-dom"]')
|
| 27 | + output2 = driver.find_element_by_id('output2').get_attribute('innerHTML') |
| 28 | + assert("Success" in output2) |
| 29 | + |
| 30 | + driver.close() |
| 31 | + driver.switch_to_window(driver.window_handles[0]) |
| 32 | + link = driver.find_element_by_link_text('new window') |
| 33 | + if platform.system() == 'Darwin': |
| 34 | + ActionChains(driver).key_down(Keys.SHIFT).click(link).key_up(Keys.SHIFT).perform() |
| 35 | + else: |
| 36 | + ActionChains(driver).key_down(Keys.CONTROL).click(link).key_up(Keys.CONTROL).perform() |
| 37 | + wait_window_handles(driver, 2) |
| 38 | + driver.switch_to_window(driver.window_handles[-1]) |
| 39 | + output = driver.find_element_by_id('output') |
| 40 | + assert(output.get_attribute('value') == '["inject-js-start","body-start","inject-js-end","onload-dom"]') |
| 41 | + output2 = driver.find_element_by_id('output2').get_attribute('innerHTML') |
| 42 | + assert("Success" in output2) |
| 43 | + |
24 | 44 | finally:
|
25 |
| - #time.sleep(50) |
26 | 45 | driver.quit()
|
0 commit comments