Jesse_Pinkman Jesse_Pinkman - 3 days ago 5
PHP Question

PHPUnit Selenium - can't find element by CSS

I am using selenium to test our software, but I have run into a problem.
There is a button like this :



<button data-action="show-more" class="btn btn-link btn-invisible more padded">Viac potenciálne zmluvy...</button>





And I am trying to select it with

$this->webDriver->findElement(WebDriverBy::cssSelector("btn.btn-link.btn-invisible.more.padded"));


And it just doesn't work. I have tried deleting some of the classes or using className - still nothing.

What am I doing wrong ?

Thank you very much

Answer

The first part of your selector is "btn" which is a class so it should be ".btn". I would go one step further and add the tag name to the front to make it a little more specific which would make the selector:

"button.btn.btn-link.btn-invisible.more.padded"
Comments