addClass every nth
try $(“ul li:nth-child(3n+1)”).addClass(“A”) $(“ul li:nth-child(3n+2)”).addClass(“B”) $(“ul li:nth-child(3n)”).addClass(“C”) Feel free to consolidate it to make it prettier, but I wanted to expose the selectors.
try $(“ul li:nth-child(3n+1)”).addClass(“A”) $(“ul li:nth-child(3n+2)”).addClass(“B”) $(“ul li:nth-child(3n)”).addClass(“C”) Feel free to consolidate it to make it prettier, but I wanted to expose the selectors.
Below is an example of the correct syntax for v4 (“& $addIcon” nested within &:hover). Further down are some v5 examples. import * as React from “react”; import { render } from “react-dom”; import { Grid, makeStyles } from “@material-ui/core”; import AddIcon from “@material-ui/icons/Add”; const useStyles = makeStyles(theme => ({ outerDiv: { backgroundColor: theme.palette.grey[200], padding: … Read more
Your issue is that you’re reading :last-of-type and thinking it works as a :last-of-class selector, when instead it specifically means elements only. There is no selector for the last instance of a class, unfortunately. From the W3C: The :last-of-type pseudo-class represents an element that is the last sibling of its type. You have p.visible:last-of-type as … Read more
To locate the element you can use either of the following Locator Strategies: CssSelector: driver.FindElement(By.CssSelector(“input#group[value=”In_Group”]”)); XPath: driver.FindElement(By.XPath(“//input[@id=’group’ and @value=”In_Group”]”)); However, as it is a <input> element and possibly you will interact with it ideally you have to induce WebDriverWait for the desired ElementToBeClickable() and you can use either of the following Locator Strategies: CssSelector: new … Read more
You can’t really use a regular expression in a selector but CSS selectors are powerful enough for your need with a “starts with” syntax inspired by regexes. You can use a substring matching attribute selectors : link[type^=service] Reads “Nodes of type link with an attribute type starting with “service” From the formal specification: [att^=val] Represents … Read more
The survey culminated in the subject selector (the proper name for the so-fabled “parent selector”) being replaced with the far more versatile :has() pseudo-class, which is documented here (with an interesting anchor name, #relational, I wonder if that will stick). Implementations will probably only arrive when the specification for this feature is more stable. Currently, … Read more
Until you find the element first, you can’t retrieve the attribute values of it. Use findElements method to fetch all links using the following locator table tr td[class=”journalTable-journalPost”] a Then iterate through each element using for-each to fetch id for each element. Sample code: List<WebElement> listOfLinks = driver.findElements(By.cssSelector(“table tr td[class=”journalTable-journalPost”] a”)); for(WebElement link: listOfLinks) { … Read more
Only text that is wrapped in HTML tags can be targeted by CSS. Your text that is not explicitly wrapped by HTML tags is algorithmically wrapped by anonymous boxes. These boxes may inherit styles, but they cannot be targeted by CSS. From the spec: 9.2.1.1 Anonymous block boxes The properties of anonymous boxes are inherited … Read more
This looks like a bug, which has finally been reported. If you add a CSS rule for divCombine CSS Attribute and Pseudo-Element Selectors? anywhere in your stylesheet with at least one declaration, your divCombine CSS Attribute and Pseudo-Element Selectors?:after rule will magically apply. For example: div:after { content: “NO”; } divCombine CSS Attribute and Pseudo-Element … Read more
For modern browsers, use td:nth-child(2) for the second td, and td:nth-child(3) for the third. Remember that these retrieve the second and third td for every row. If you need compatibility with IE older than version 9, use sibling combinators or JavaScript as suggested by Tim. Also see my answer to this related question for an … Read more