How to test CSS values in Python using selenium?
try the below code :
some_value = driver.find_element_by_xpath("//style[2]").get_attribute('innerHTML')print(some_value)
output :
.video-dimensions { width: 300px; height: 168.75px; } .video-dimensions.vjs-fluid { padding-top: 56.25%; }
Now if you just want to get width value probably the below code should work for you :
some_value = driver.find_element_by_xpath("//style[2]").get_attribute('innerHTML').strip()arr = some_value.split(":")ar = arr[1].split(";")print(ar[0])
or
some_value = driver.find_element_by_xpath("//style[2]").get_attribute('innerHTML').strip()arr = some_value.split(":")[1].split(";")[0]print(arr)
should print 300px
in this case.