Web 要素の背景色を 16 進数形式で見つけるにはどうすればよいですか? 現在の Selenium Webdriver python コードでは、背景色を RGB 形式で返しています。
これは私が見ているhtml要素です
div class="bar" style="background-color: #DD514C; background-image: -moz-linear-gradient(center top , #EE5F5B, #C43C35); background-image: -webkit-linear-gradient(top , #EE5F5B, #C43C35); background-image: -ms-linear-gradient(top , #EE5F5B, #C43C35); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#EE5F5B, endColorstr=#C43C35, GradientType=0); background-repeat: repeat-x; color: #ffffff; width: 11.5%"
私のウェブドライバーのpythonコードは次のとおりです。
find_element_by_class_name("bar").get_attribute("style")
RGB形式の色でスタイルを返しています。期待値と比較できるように、背景色を16進数形式で具体的に取得したいと考えています。現在、次の出力が得られています。
background-color: rgb(221, 81, 76); background-image: -moz-linear-gradient(center top , rgb(238, 95, 91), rgb(196, 60, 53)); background-repeat: repeat-x; color: rgb(255, 255, 255); width: 11.5%;