Css selector for elements with style attribute

前端 未结 3 409
长情又很酷
长情又很酷 2021-01-03 10:39

I have an element with the following styles

Now I want to se

相关标签:
3条回答
  • 2021-01-03 11:15

    A possible solution is to select all elements with matching class name, then the first of those with the correct style attribute. You haven't said which language the test is written in, but an example in C# would be:

    IWebElement element = driver.FindElements(By.CssSelector("ul.textboxlist-bits")).First(e => e.GetAttribute("style").Contains("background-color: transparent;"));

    0 讨论(0)
  • 2021-01-03 11:15

    Maybe this http://reference.sitepoint.com/css/elementtypeselector not sure if you mean something like an if statement in c?

    [ { attribute | attribute { = | |= | ~= } attribute value } ] {
    
    declare stuff here..
    
     }
    

    or

    this matches any type input that matches 'submit'

     input[type="submit"] {
      declarations
    }
    
    0 讨论(0)
  • 2021-01-03 11:20

    I think you only have to remove the first space:

    ul[style="background-color: transparent;"]
    

    Now it is searching all ul-tags which have this style; with the space between it tries to select all dom elements in(!) a ul-tag which have this sytle.

    Here an example with the querySelector for javascript, it should work with selenium too.

    0 讨论(0)
提交回复
热议问题