-2

I have a button in the page :

<div class="button wide green attached connectyourself" >Conect</div>

I want tu push on this div, so I create the methode :

/**
 * @When I open the connection popup
 */
public function iOpenTheConnectionPopup()
{
    $page = $this->getSession()->getPage();
    $findName = $page->find("css", '.connectyourself');
    if (!$findName) {
        throw new Exception('connectyourself' . " could not be found");
    } else {
        $findName->click();
    }
}

Every time I get the exception 'connectyourself could not be found'. Can you help me please ?

user7424312
  • 127
  • 2
  • 10
  • 1
    Your check if the element was found is not correct, `find` returns an object or null so you should use `=== null` instead of `!$findName` also check if your selector returns a single element and finally maybe you need some wait, check here https://stackoverflow.com/questions/42911114/fatal-error-call-to-a-member-function-press-on-a-non-object/42925010 – lauda Jun 29 '17 at 08:16
  • as @lauda mentioned, please check your if statement, and consider waiting for the element before searching for it. Finally, you might refine your CSS selector to div.connectyourself – Breaks Software Jun 29 '17 at 11:36

1 Answers1

0

I think this css is not unique. Might be there are more elements with the class name containing "connectyourself". You should try finding it by giving a full class nam.

$findName = $page->find("css", '.button.wide.green.attached.connectyourself');
Monika
  • 674
  • 1
  • 4
  • 10