your xpath is searching for @style="*display: block*"
, it means totally equal to value inside quotes. Use contains()
instead,
Fyi: there's also starts-with()
method
//div[@class='foo'][contains(@style,'display: block')]
There's an issue with using such locator, as sometimes element is visible, though there's no style display:block
. So you can use similar locator, but instead of containing block, searche for not-containing "none" (as in display:none), can try it by adding this to main locator [not(contains(@style, 'none'))]
. Just remember about such option)