Esempio n. 1
0
 public function testBooking()
 {
     WebDriver::instance()->get("http://trivago.com");
     Helper::waitUntilDocumentIsLoaded();
     // asset serch box is present and visible on page
     Assert::elementFound(TrivagoHome::getSelector("searchBox"));
     // enter search string in search box
     TrivagoHome::getElement("searchBox")->sendKeys(self::SEARCH_CITY);
     // wait untill suggestion list appears
     try {
         Helper::waitUntilVisible(TrivagoHome::getSelector("suggestions"));
     } catch (Exception $e) {
         $this->fail("After entering city name in search box, suggestion list did not appear");
     }
     // suggeation list is visible, pick matching one
     $matchingCity = TrivagoHome::getMatchingOptionFromSuggestionDropdown(self::SEARCH_CITY, self::SERCH_COUNTRY);
     // assert we see expected option in suggestion list
     $this->assertFalse($matchingCity == null, "Expected option Hamburg (Germany) do not appear in suggestion list");
     // we have matching city in option list
     $matchingCity->click();
     // lets calender be visible
     sleep(1);
     $this->assertTrue(TrivagoHome::getElement("calendarPopup")->isDisplayed(), "After clicking on city from suggestion list, Calendar did not appear");
     // close calendar in order to see the hotel list
     TrivagoHome::closeCalendar();
     // hotel list is reloaded after intial load. hence wait
     // TODO: figure out better way to wait than just sleep for harcoded time
     sleep(6);
     TrivagoHome::waitUntilHotelListIsLoaded();
     // collect all hotels from search list
     $hotels = TrivagoHome::getHotels();
     // make sure we have sufficient hotels in list
     $this->assertTrue(count($hotels) > 2, "Not sufficient hotels found in list");
     // as per test case, we need to pick second hotels from list
     // scroll page up before clicking on view all deals link
     Helper::scrollPageToBottomByPixel(300);
     $hotels[1]->viewAllDealsClick();
     $hotels[1]->waitUntilDealsIsLoaded();
     $hotelName = $hotels[1]->getName();
     // deals are visible now
     $deals = $hotels[1]->getAllDeals();
     // make sure we have few deals in list
     $this->assertTrue(count($deals) > 2, "Not sufficient deals found in list");
     // as per test, click on third deal
     $deals[2]->click();
     Helper::waitUntilPopupUrlContains('www.trivago');
     // lets third party website load its content
     sleep(2);
     $window = new Window();
     $this->assertTrue(Util::hasString($window->getText(), $hotelName, true), "Expected hotel name '{$hotelName}' do not found on partner website");
     $window->close();
 }
Esempio n. 2
0
 /**
  * return element horizontal alignment relative to given container or browser screen
  * 
  */
 static function getElementHorizontalAlignment($element, $container = NULL)
 {
     $alignments = [];
     if ($container) {
         $left = self::getElementX($container);
         $width = self::getElementWidth($container);
     } else {
         // take browser  as container
         $left = 0;
         $width = Helper::getBrowserClientWidth();
     }
     $center = $width == 0 ? $left : $left + $width / 2;
     $elementLeft = self::getElementX($element);
     $elementWidth = self::getElementWidth($element);
     $elementCenter = $elementWidth == 0 ? $elementLeft : $elementLeft + $elementWidth / 2;
     if ($elementLeft == $left) {
         $alignments[] = 'LEFT';
     }
     if ($elementLeft + $elementWidth == $width) {
         $alignments[] = 'RIGHT';
     }
     if (abs($elementCenter - $center) <= 1) {
         $alignments[] = 'CENTER';
     }
     return $alignments;
 }