在selenium应用,CSS比XPATH更性感
To style an element, Front end developers need to locate the element first and then apply styling rules. It looks like this:
#logo{ color: white; background: black; }
That CSS snippet says, apply color and background styles to any element with an ID
of logo
. Normally, ID will be unique in any HTML document carefully crafted. But there are chances for multiple developers working on the same page to use the same ID for different elements. Most of the time, without knowing it is already being used. Don’t worry, they’ll eventually catch up with that bug, but the point is the browser throws no warning. You should tell the developers when you find such scenarios.
The JavaScript developer who wants to take the logo for a spin writes code like this:
let element=document.querySelector(“#logo”); rotate(element);