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.