没有找到xpath的元素代码

时间:2021-02-21 22:17:34

I am using CodeCeption to test a website for work. I've never used CodeCeption and I'm just trying to get my first test to work. I just want to login, but my login box is using jQuery UI (which means the login button doesn't have an ID). The website is https://moveyourmountain.org

我正在使用CodeCeption来测试网站的工作。我从来没有使用CodeCeption,我只是想让我的第一个测试工作。我只是想登录,但我的登录框是使用jQuery UI(这意味着登录按钮没有ID)。该网站是https://moveyourmountain.org

I used this in the Chome Console:

我在Chome控制台中使用了这个:

$x('//button/span[text()="Login"]')

and got this response:

得到了这个回应:

[<span class=​"ui-button-text">​Login​</span>​]

so my xpath is right, and selects the right thing. However, in CodeCeption I have this:

所以我的xpath是正确的,并选择正确的东西。但是,在CodeCeption中我有这个:

$I = new AcceptanceTester($scenario);
$I->wantTo('Login as a regular user.');
$I->amOnPage('/');
$I->click('LOGIN');
$I->fillField('email', 'some@one.com');
$I->fillField('password', 'test123');
$I->click(['xpath' => '//button/span[text()="Login"]']);
$I->see('MY ACCOUNT');

and every time I run it I get this in my terminal:

每次我运行它我都在我的终端:

Sorry, I couldn't click {"xpath":"//button/span[text()="Login"]"}:
Element with xpath '//button/span[text()="Login"]' was not found on page.

Scenario Steps:
5. I click {"xpath":"//button/span[text()="Login"]"}
4. I fill field "password","test123"
3. I fill field "email","some@one.com"
2. I click "LOGIN"
1. I am on page "/"

I am using PhpBrowser if that makes a difference. Any help is appreciated. I have no idea how to go about testing this because it obviously isn't resolving the same as chrome.

如果有所作为,我正在使用PhpBrowser。任何帮助表示赞赏。我不知道如何测试这个,因为它显然不像chrome那样解析。

1 个解决方案

#1


1  

Try to change your acceptance.suite.yml.

尝试更改您的acceptance.suite.yml。

Instead of PhpBrowser use WebDriver.

而不是PhpBrowser使用WebDriver。

#1


1  

Try to change your acceptance.suite.yml.

尝试更改您的acceptance.suite.yml。

Instead of PhpBrowser use WebDriver.

而不是PhpBrowser使用WebDriver。