doubu0897 2018-08-08 14:46
浏览 525

保持登录状态(保留cookie)WebDriver / Codeception / Selenium

Setps:

  • 1.Login.
  • 2.Go to Profile.
  • 3.Go to Bookings.
  • 4.Iterate through bookings till something is found.
  • 5.Do some other stuff on the booking detail page

Problem at 4.

When clicking on any Booking it redirects me to the login page, even thoght I was logged in first.

As requested all steps are here.

private function executeLogin(\AcceptanceTester $I)
{
    $I->amOnPage('/de/account/login');

    $I->fillField('#_username', 'user');
    $I->fillField('#_password', 'somepw');
    $I->click('body > div > main > div > form > div > div > button');
}


public function logIn(\AcceptanceTester $I )
{
    $I->wantTo('Log-in to My Website');

    $this->executeLogin($I);
}


public function goToBookings(\AcceptanceTester $I)
{
    $I->wantTo('Go to all my Bookings Page');

    $flyOutButton = '.nav-main__link-flyout.nav-account';
    $myBookingsButton = '/html/body/div/header/div/div/div/nav/ul/li[2]/div/div/div/ul/li[3]/a';

    $I->moveMouseOver($flyOutButton);
    $I->moveMouseOver($myBookingsButton);
    $I->click($myBookingsButton);

}

public function checkForExtra(\AcceptanceTester $I)
{
    $I->wantTo('Go through all Bookings and check if Extras are Available');

    $extrasCounter = 1;

    do{
        // $I->click('/html/body/div/main/div/div[2]/div['.$extrasCounter.']/a/div/article/div/div/div/button');
        $I->click('/html/body/div/main/div/div[2]/div['.$extrasCounter.']/a');

        //TODO Here it Redirects to the Login // Should go to the booking details Page
        $grabExtrasID = $I->grabMultiple('#add-extras-link');
        $totalExtras = count($grabExtrasID);

        $extrasCounter++;

        if ($totalExtras === 1){
            break;
        }

        codecept_debug($totalExtras);

        $I->moveBack();

    }while($totalExtras == 0);
}

The $I->Click is where i get logged out / redirected to the login. And not to the whole booking details page.

Console Output

    I click "/html/body/div/main/div/div[2]/div[1]/a/div/article/div/div/div/button"
 I grab multiple "#add-extras-link"
 I move back
  /de/account/bookings
  0
 I click "/html/body/div/main/div/div[2]/div[2]/a/div/article/div/div/div/button"
 I grab multiple "#add-extras-link"
 I move back
  /de/account/bookings
  0
 I click "/html/body/div/main/div/div[2]/div[3]/a/div/article/div/div/div/button"
 I grab multiple "#add-extras-link"
 I move back
  /de/account/bookings
  0
 I click "/html/body/div/main/div/div[2]/div[4]/a/div/article/div/div/div/button"
 I grab multiple "#add-extras-link"
 I move back
  /de/account/bookings
  0
 I click "/html/body/div/main/div/div[2]/div[5]/a/div/article/div/div/div/button"
 I grab multiple "#add-extras-link"
 I move back
  /de/account/bookings
  0

As you can see the 0 indicates it found 0 classes from what im looking for. There are at least 3 bookings with the class. This is because It does not even go to the booking details page.

I hope this makes sense, please let me know if there is other Information you need.

Thank you.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器