css-selectors

Can you apply CSS rules, in CSS, if a div doesn't exist?

烈酒焚心 提交于 2020-11-25 13:45:53
问题 Is this possible, with CSS ? Apply this rule if .div1 doesn't exist: .div2{ property: value; } like <div class="div1"> ... </div> <div class="div2"> <!-- it exists, so do nothing --> </div> and <div class="div2"> <!-- it doesn't exist, apply the css --> </div> 回答1: If you know the 'unstyled' styles of the div, you could use a css sibling selector to style it one way if it follows .div1, and the 'plain' way if it doesnt - ie .div2 { /* styled however you want */ } .div1 + .div2 { /* 'plain'

Assert if text within an element contains specific partial text

痞子三分冷 提交于 2020-11-25 04:36:07
问题 I have an element within tag that has release notes. I have to validate if it contains specific text. I am able to extract the text using following code: WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located((By.XPATH, ManageSoftware.release_notes_xpath))).get_attribute("innerHTML") How do I assert if it contain a specific text, say "abc". Is there any function like contains() or isPresent() that I can use here? The code that I am working on is: <div id="dialog" class="ui