콘솔워크

python selenium element css 정보 가져오기 value_of_css_property 본문

프로그래밍/python

python selenium element css 정보 가져오기 value_of_css_property

콘솔워크 2022. 8. 20. 08:57
반응형

특정 엘리먼트의 css 정보를 가져올일이 생겼다.

 

css에만 있는 정보여서 한참 해멨다. 키워드는 value_of_css_property 이다.

 

예시)

background_color:str = td_el.find_element(By.XPATH, 'span').value_of_css_property('background')

 

 

보통은 attribute를 가지고 오고 싶을 때는 [엘리먼트].find_element(셀렉터).get_attribute('textContent') 이렇게 하면 된다.

 

 

핵심은. 간단하다.

 

css property 정보 가지고 오고 싶을 때는 value_of_css_property 

 

attribute 정보가지고 오고 싶을 때는 get_attribute

 

반응형