-2

I'm writing a small test program where I want to reach login form and to fill it. However, I receive an error. enter image description here

Here's what I got in my code:

<?php

class loginCest
{
    public function frontpageWorks(AcceptanceTester $I)
    {

        $I->wantTo("Create login test");
        $I->amOnPage('my link');
        $I->see("join");
        $I->fillField('.form-control', 'my_login');
    }
}
HenrikasB
  • 321
  • 1
  • 9
  • 1
    ___However, I receive an error.___ Could you share the error with us please – RiggsFolly Feb 24 '19 at 14:34
  • 1) loginCest: Create login test Test tests\acceptance\loginCest.php:frontpageWorks Step Fill field ".form-control","email" Fail Form field by Label or CSS element with '.form-control' was not found. – HenrikasB Feb 24 '19 at 14:37
  • have you tried a different selector than only the class? A strict locator even maybe? Like `$I->fillField(['name' => 'userIdentifier'], 'my_login');` - I guess codeceptions finds more than one element with `.form-control`, or even a non-input. – Jeff Feb 24 '19 at 14:47
  • 2
    The error cites "Email" form field, which isn't in the shown test, not in the shown html. Maybe the error referrs to something different than you think? – Jeff Feb 24 '19 at 14:48
  • The field requires email address, is there other command to enter for email? – HenrikasB Feb 24 '19 at 14:48
  • Still need a help with this problem. – HenrikasB Feb 24 '19 at 19:17
  • Solved. @Jeff's suggest worked – HenrikasB Mar 06 '19 at 17:54
  • I made it an answer then. – Jeff Mar 06 '19 at 21:49

1 Answers1

0

I would try with a strict locator like:

$I->fillField(['name' => 'userIdentifier'], 'my_login');

because codeceptions might find more than one element (and even a non-input) with the class .form-control

Jeff
  • 6,895
  • 1
  • 15
  • 33