Home » Php » php – How to solve "element not interactable" with ChromDriver and yii2?

php – How to solve "element not interactable" with ChromDriver and yii2?

Posted by: admin February 25, 2020 Leave a comment

Questions:

At first i work with OpenServer and I use ChromeDriver like this

D:\ChromeDriver\chromedriver.exe --url-base=/wd/hub

My Acceptance.suite.yml

class_name: AcceptanceTester
modules:
    enabled:
        - WebDriver:
              url: http://arctic/
              window_size: false # disabled in ChromeDriver
              port: 9515
              browser: chrome
        - Yii2:
            part: orm
            entryScript: index-test.php
            cleanup: false

My acceptance test

public function _before(AcceptanceTester $I)
{
    $I->amOnPage('/admin');
    $I->fillField('FormLogin[username]', 'admin');
    $I->fillField('FormLogin[password]', 'admin');
    $I->click('Войти');
    $I->click('Меню');
}

And i got this error

1) AdminMenuAcceptCest: Try to test
 Test  tests\acceptance\AdminMenuAcceptCest.php:tryToTest

  [Facebook\WebDriver\Exception\ElementNotInteractableException] element not interactable
  (Session info: chrome=80.0.3987.100)  


Scenario Steps:

 2. $I->fillField("FormLogin[username]","admin") at tests\acceptance\AdminMenuAcceptCest.php:8
 1. $I->amOnPage("/admin/main") at tests\acceptance\AdminMenuAcceptCest.php:7

#1  D:\OSPanel-new\domains\arctic_dev\vendor\php-webdriver\webdriver\lib\Exception\WebDriverException.php:95
#2  D:\OSPanel-new\domains\arctic_dev\vendor\php-webdriver\webdriver\lib\Remote\HttpCommandExecutor.php:370
#3  D:\OSPanel-new\domains\arctic_dev\vendor\php-webdriver\webdriver\lib\Remote\RemoteWebDriver.php:584
#4  D:\OSPanel-new\domains\arctic_dev\vendor\php-webdriver\webdriver\lib\Remote\RemoteExecuteMethod.php:27
#5  D:\OSPanel-new\domains\arctic_dev\vendor\php-webdriver\webdriver\lib\Remote\RemoteWebElement.php:60
#6  Codeception\Module\WebDriver->fillField
#7  D:\OSPanel-new\domains\arctic_dev\tests\_support\_generated\AcceptanceTesterActions.php:1505
#8  D:\OSPanel-new\domains\arctic_dev\tests\acceptance\AdminMenuAcceptCest.php:8
#9  AdminMenuAcceptCest->_before

I tried to check for existing of field in $I->seeElement() and it didn’t see it.

How to&Answers:

It might be helpful for someone, this is my solution:

public function _before(AcceptanceTester $I)
    {
        $I->amOnPage('/admin');
        $I->executeInSelenium(function(\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
            $webdriver->executeScript("$('#login_block').modal('show');");
        });
        $I->wait(5);
        $I->fillField('FormLogin[username]', 'admin');
        $I->fillField('FormLogin[password]', 'admin');
        $I->click('Войти');
    }