気になったこと、勉強したこと、その他雑記など色々メモしていきます。。Sometimes these posts will be written in English.,

Trap on findElement with cssSelector for Facebook WebDriver

In my case using Facebook WebDriver for Headless browser Testing, there is a trap on findElement with cssSelector.
Assume you want to find the element(s) by css selector that you specify like what their style attribute doesn't have "display:none",
for example you would use WebDriverBy::cssSelector like below.

Facebook WebDriverをテストで使っていて、その時にcssSelectorを使ってfindElementする際のトラップの話。

WebDriverBy::cssSelector("ul li:not([style*='display:none'])")

Although above aims to specify "li" which is visible element located in "ul", you cannot find them if they have half space between "display" and "none". In this case
you have to do insert a half space in the selector like this.

この場合、以下のようにcss selectorに半角スペースを入れる必要がある。

WebDriverBy::cssSelector("ul li:not([style*='display: none'])")

Besides I tried to use ":visible" selector for WebDriverBy::cssSelector(), but It didn't work with log "invalid selector ~".

また、:visibleセレクターも試したけどinvalid selector~~と言われてダメでした。。