src/Services/InteractWithPage.php
protected function findElement($name)
    {
        try {
            return $this->wd->findElement(WebDriverBy::id($name));
        } catch (\Exception $e) {
        }

        try {
            return $this->wd->findElement(WebDriverBy::name($name));
        } catch (\Exception $e) {
        }

        try {
            return $this->wd->findElement(WebDriverBy::cssSelector($name));
        } catch (\Exception $e) {
        }

        try {
            return $this->wd->findElement(WebDriverBy::xpath($name));
        } catch (\Exception $e) {
        }

        throw new CannotFindElement('Cannot find element: '.$value.' isn\'t visible on the page');
    }
protected function findElement($name)
    {
        try {
            return $this->wd->findElement(WebDriverBy::id($name));
        } catch (\Exception $e) {
        }

        try {
            return $this->wd->findElement(WebDriverBy::name($name));
        } catch (\Exception $e) {
        }

        try {
            return $this->wd->findElement(WebDriverBy::cssSelector($name));
        } catch (\Exception $e) {
        }

        try {
            return $this->wd->findElement(WebDriverBy::xpath($name));
        } catch (\Exception $e) {
        }

        throw new CannotFindElement('Cannot find element: '.$value.' isn\'t visible on the page');
    }
protected function findElement ( $ name ) { try { return $ this -> wd -> findElement ( WebDriverBy :: id ( $ name ) ) ; } catch ( \ Exception $ e ) { } try { return $ this -> wd -> findElement ( WebDriverBy :: name ( $ name ) ) ; } catch ( \ Exception $ e ) { } try { return $ this -> wd -> findElement ( WebDriverBy :: cssSelector ( $ name ) ) ; } catch ( \ Exception $ e ) { } try { return $ this -> wd -> findElement ( WebDriverBy :: xpath ( $ name ) ) ; } catch ( \ Exception $ e ) { } throw new CannotFindElement ( 'Cannot find element: ' . $ value . ' isn\'t visible on the page' ) ; }
Will attempt to find an element by different patterns
If xpath is provided, will attempt to find by that first.

@param null $name

@throws CannotFindElement

@return \Facebook\WebDriver\Remote\RemoteWebElement
Will attempt to find an element by different patterns If xpath is provided will attempt to find by that first .