防止清除cookie欺骗webdriver

Prevent clear cookies codeception webdriver

本文关键字:欺骗 webdriver cookie 清除      更新时间:2023-09-26

我必须测试单页JavaScript应用程序。完成测试后的动作看起来像WebDriver清除cookie。有可能预防吗?我需要在互不隔离的情况下运行测试。

测试文件:

<?php

class ClientGroenCest
{
    protected $selectors = [
        'clientTableElements' => '.b-content__clients > div:first-child > div:first-child .b-table-v2.b-table__clients tbody .nano tr',
        'clientTableFirstElement' => '.b-content__clients > div:first-child > div:first-child .b-table-v2.b-table__clients tbody .nano tr:first-child',
    ];
    public function _before(AcceptanceTester $I)
    {
    }
    public function _after(AcceptanceTester $I)
    {
    }
        // tests
public function login(AcceptanceTester $I)
{
    $I->amOnPage('/');
    $I->fillField('#loginform-email', 'test2@test.ru');
    $I->fillField('#loginform-password', 'qweewq');
    $I->wait(1);
    $I->click('button[type="submit"]');
    $I->dontSeeCurrentUrlEquals('/login');
    $I->dontSeeCurrentUrlEquals('/site/login');
    $I->dontSeeCurrentUrlEquals('/');
}
public function checkNumberOfClients(AcceptanceTester $I)
{
    $I->click($this->selectors['clientTableFirstElement']);
    $I->wait(5);
}

acceptance.suite.yml:

class_name: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: https://crm.loc
            browser: chrome
            delay: 5000
            window_size: maximize
            capabilities:
                acceptSslCerts: true
                trustAllSSLCertificates: true
        - 'Helper'Acceptance
        - Yii2:
            configFile: 'config/test.php'
            part: ORM # allow to use AR methods
            cleanup: false # don't wrap test in transaction
            entryScript: index-test.php

需要使用clear_cookies来保存动作的状态。

http://codeception.com/docs/modules/WebDriver配置