javascript - python selenium send css with !important -
i change css of element follows. works fine when:
browser.execute_script( "arguments[0].style.display = 'block';", browser.find_element_by_xpath("//div[@role='main']/div/div/div["+str(d)+"]/div["+str(r)+"]/div/div[2]") )
but when try add "!important", code not updated:
browser.execute_script( "arguments[0].style.display = 'block!important';", browser.find_element_by_xpath("//div[@role='main']/div/div/div["+str(d)+"]/div["+str(r)+"]/div/div[2]") )
the statement element.style.display = 'block' work setting value of valid property values. since 'block !important' not recognized, not added. !important declaration.
you can use .setproperty() instead, let add more value. use 'important' string , don't add exclamation point.
browser.execute_script( "arguments[0].style.setproperty('display', 'block', 'important');", browser.find_element_by_xpath("//div") )
Comments
Post a Comment