Selenium์ ์ฌ์ฉํ๋ค ๋ณด๋ฉด ๊ฐ๋ ๋ด๊ฐ ์ฐพ๋ ์์์ ์ขํ๊ฐ ํ์ํ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค. ์ด๋ด ๋ ๋ด๊ฐ ์ฐพ๊ณ ์ ํ๋ Element ์ขํ๋ฅผ
๊ฐ์ ธ์ค๋ ์ฝ๋๋ฅผ ์ฌ์ฉํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
์ ๋ ํฌ๋กฌ๋๋ผ์ด๋ฒ๋ฅผ ์ฌ์ฉํ์์ต๋๋ค.
์ ๋ ๊ฐ๋จํ๊ฒ ํ์ด์ง ์๋จ์ ์๋ ๋ก๊ณ ์ ์ขํ๋ฅผ ๊ฐ์ ธ์ค๋๋ก ํด๋ณด๊ฒ ์ต๋๋ค.
โถ๏ธ ์์ ์ฐพ๊ธฐ
# ์์ ์ฐพ๊ธฐ
logo_icon = driver.find_element(By.CLASS_NAME, 'Header__LogoIcon')
# ์ฐพ์ ์์์ ์ขํ๊ฐ ๊ฐ์ ธ์ค๊ธฐ
icon_location = logo_icon.location
# ์ขํ ๊ฐ ์ถ์ถํ๊ธฐ
print(icon_location)
# ์ฌ์ฉํด๋ณด์ธ์!
elem = driver.find_element(By.์๋ฆฌ๋จผํธ(์ : Xpath), '์์ฑ๊ฐ ์
๋ ฅ')
location = elem.location
print(location)โ
'๐ฅ Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Selenium] UI์๋ํ์์ ์์ฃผ ์ฌ์ฉํ๋ ๋ฉ์๋ (2) | 2024.09.13 |
---|---|
[Selenium] find_element(By.) ์ฌ์ฉํ๊ธฐ (0) | 2023.08.12 |
[Selenium] Element ํ ์คํธ ์ถ์ถํ๊ธฐ (0) | 2023.04.22 |
[Selenium] ํ์ด์ง ์คํฌ๋กค ํ๊ธฐ (0) | 2023.03.20 |
[Selenium] iframe ์ ํํ๊ธฐ (1) | 2023.01.25 |