E
E
Evgeny Musonov2020-02-13 12:27:00
Codeception
Evgeny Musonov, 2020-02-13 12:27:00

How to fix element not interactable error?

I use Chrome Driver (Yii2 framework), I run this command

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

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

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

Mistake
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

The first time the test worked fine, I entered the data and logged in, the second time I got an error, what could be the reason for this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Musonov, 2020-04-02
@evmusonov

The error occurs due to JS that does not have time to work out (or does not work out at all), adding this code solved the problem

$I->executeInSelenium(function(RemoteWebDriver $webdriver) {
      $webdriver->executeScript("$('#login_block').modal('show');");
    });

The element was hidden so the handler didn't see it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question