Selenium finds element, but can't interact with it due to element ID missing

305 Views Asked by At

So I had a perfectly working code, up until I was playing with other parts of the script today, and one part all of a suddent stopped working, my code is:

$host = 'http://host.com:4444/wd/hub';
$caps= DesiredCapabilities::chrome();
$options = new ChromeOptions();
$options->addArguments(['--headless','--no-sandbox', '--window-size=1000,1000']);
$caps->setCapability(ChromeOptions::CAPABILITY, $options);
$driver = RemoteWebDriver::create($host, $caps, 5000);

$driver->manage()->deleteAllCookies();

echo "[".date("r")."]"."---- LOGIN PROCESS ---- \n";

$driver->get("https://www.example.com/login/");

$driver->wait(10)->until(
    WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(
        WebDriverBy::name('password')
    )
);
$driver->takeScreenshot('image.png');
$driver->findElement(WebDriverBy::name('username'))->click();

The element is a text field, sending keys to it produces the same exception, which is:

Fatal error: Uncaught Facebook\WebDriver\Exception\UnknownCommandException: POST /session/330d05c02583a90a227cddf8c9db000a/element//click
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'srv1.scoding.com', ip: '209.4*****', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-957.12.2.vz7.96.21', java.version: '1.8.0_232'
Driver info: driver.version: unknown in /path/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:106
Stack trace:
#0 /path/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php(326): Facebook\WebDriver\Exception\WebDriverException::throwException(9, 'POST /session/3...', Array)
#1 /path/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php(547): Facebook\WebDriver\Remote\HttpCommandExecutor->execute(Object(Facebook\WebDriver\Remote\WebDriverCommand))
#2 /path/vendor/facebook/webdriver/lib/Remote/RemoteExecuteMethod.php(40): Facebook\WebDr in /path/vendor/facebook/webdriver/lib/Exception/WebDriverException.php on line 106

Yet if I just look for the element and dump out the return, it's not saying anything about not being able to locate it:

Facebook\WebDriver\Remote\RemoteWebElement Object
(
    [executor:protected] => Facebook\WebDriver\Remote\RemoteExecuteMethod Object
        (
            [driver:Facebook\WebDriver\Remote\RemoteExecuteMethod:private] => Facebook\WebDriver\Remote\RemoteWebDriver Object
                (
                    [executor:protected] => Facebook\WebDriver\Remote\HttpCommandExecutor Object
                        (
                            [url:protected] => http://host.com:4444/wd/hub
                            [curl:protected] => Resource id #26
                        )

                    [capabilities:protected] => Facebook\WebDriver\Remote\DesiredCapabilities Object
                        (
                            [capabilities:Facebook\WebDriver\Remote\DesiredCapabilities:private] => Array
                                (
                                    [acceptInsecureCerts] => 
                                    [browserName] => chrome
                                    [browserVersion] => 78.0.3904.70
                                    [chrome] => Array
                                        (
                                            [chromedriverVersion] => 77.0.3865.90 (58c425ba843df2918d9d4b409331972646c393dd-refs/branch-heads/3865@{#830})
                                            [userDataDir] => /tmp/.org.chromium.Chromium.K53sGg
                                        )

                                    [goog:chromeOptions] => Array
                                        (
                                            [debuggerAddress] => localhost:45159
                                        )

                                    [networkConnectionEnabled] => 
                                    [pageLoadStrategy] => normal
                                    [platformName] => linux
                                    [proxy] => Array
                                        (
                                        )

                                    [setWindowRect] => 1
                                    [strictFileInteractability] => 
                                    [timeouts] => Array
                                        (
                                            [implicit] => 0
                                            [pageLoad] => 300000
                                            [script] => 30000
                                        )

                                    [unhandledPromptBehavior] => dismiss and notify
                                    [webdriver.remote.sessionid] => c2fdfaac32d39a20d3def74b7c15ab5b
                                )

                        )

                    [sessionID:protected] => c2fdfaac32d39a20d3def74b7c15ab5b
                    [mouse:protected] => 
                    [keyboard:protected] => 
                    [touch:protected] => 
                    [executeMethod:protected] => Facebook\WebDriver\Remote\RemoteExecuteMethod Object
 *RECURSION*
                )

        )

    [id:protected] => 
    [fileDetector:protected] => Facebook\WebDriver\Remote\UselessFileDetector Object
        (
        )

)

Anyone have any clue what I'm doing wrong? It's not within an iframe, it's present, there's no dialog, nothing.. Note that in the click error, there is no element ID: POST /session/330d05c02583a90a227cddf8c9db000a/element//click

But in terms of the libraries, I have not changed anything?

1

There are 1 best solutions below

0
On BEST ANSWER

The issue seems to of been within the library, not sure what happened, but running composer remove and then requiring it again solved it.