forked from careerist-qa/python-selenium-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframes.py
More file actions
28 lines (20 loc) · 852 Bytes
/
Copy pathframes.py
File metadata and controls
28 lines (20 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
#init driver
driver_path = ChromeDriverManager().install()
service = Service(driver_path)
driver = webdriver.Chrome(service=service)
driver.implicitly_wait(4)
#open url
driver.get("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe")
#switch to frame 1
driver.switch_to.frame("iframeResult")
#switch to frame 2
frame2 = driver.find_element(By.CSS_SELECTOR, "iframe[src='https://www.w3schools.com']")
driver.switch_to.frame(frame2)
menu = driver.find_element(By.CSS_SELECTOR, '.tnb-menu-btn')
print(menu.get_attribute('title'))
assert menu.get_attribute('title') == 'Menu', f"Title is {menu.get_attribute('title')} instead of Menu"
driver.quit()