phpajaxselenium-webdrivercodeceptionacceptance-testing

Codeception with Webdriver $I->fillField not working although the field is seen


Being pretty new to Codeception I am having a problem with the following code:

$I->click("a.slideout-toggle-add-employee");
$I->wait(2);
$I->seeElement(Locator::find('input', ['placeholder' => 'Vorname']));
$I->fillField(Locator::find('input', ['placeholder' => 'Vorname']),"Testerina");
$I->wait(2);

The output when running codecept run is like this:

 I click "a.slideout-toggle-add-employee"
 I wait 2
 I see element "//input[@placeholder = 'Vorname']"
 I fill field "//input[@placeholder = 'Vorname']","Testerina"
  Screenshot and page source were saved into '...' dir
 ERROR 

In my setup I am using selenium-standalone and the following configuration:

class_name: AcceptanceTester
actor: AcceptanceTester
modules:
  enabled:
    - WebDriver:
        url: 'http://localhost:19080/'
        browser: chrome
        host: '127.0.0.1'
        port: 4444
        restart: false
        window_size: 1920x1080
    - \Helper\Acceptance
    - Asserts

In a similar question I have read that fillField can be a problem with PhpBrowser but this does not answer my question: seeInField finds the element, while fillField doesn't - CodeCeption

The is probably delivered via ajax within the page but as the element is found with the locator I do not understand what is wrong. What am I missing?


Solution

  • Finally found an answer - there was some unknown hidden element which matched the same selector and this element caused an Exception:

    [Facebook\WebDriver\Exception\ElementNotInteractableException] element not interactable.

    I found out using the grabMultiple function:

    print_r($I->grabMultiple(Locator::find('input', ['placeholder' => 'Vorname'])));

    The solution was to use a more specific selector:

    $I->fillField('.employees-list input[name="user_firstname"]',"Testerina");