Esempio n. 1
0
 def moveListing(self, numberOfMoves, right=True):
     # for i in range(numberOfMoves):
     #     time.sleep(6)
     #     ac = ActionChains(self.driver)
     #     ac.move_to_element(self.canvas())
     #     ac.move_by_offset(100, 0)
     #     ac.move_by_offset(100, 0)
     #     ac.click_and_hold()
     #     if right:
     #         ac.move_by_offset(-1*int(self.canvas().size["width"]/8), 0)
     #     else:
     #         ac.move_by_offset(int(self.canvas().size["width"]/8), 0)
     #     ac.release()
     #     ac.perform()
     #     time.sleep(2)
     #     self.log.screenshot("nakon pomeranje")
     scroll_element_to_center(self.driver, self.log, self.canvas())
     for i in range(numberOfMoves):
         time.sleep(6)
         ActionChains(self.driver).move_to_element(self.canvas()).perform()
         ActionChains(self.driver).click_and_hold().perform()
         if right:
             ActionChains(self.driver).move_by_offset(
                 -1 * int(self.canvas().size["width"] / 8), 0).perform()
         else:
             ActionChains(self.driver).move_by_offset(
                 int(self.canvas().size["width"] / 8), 0).perform()
         ActionChains(self.driver).release().perform()
         time.sleep(2)
         self.log.screenshot("Listing moved")
Esempio n. 2
0
    def _add_button_to_center_firefox(self, hotSpot):
        """
        Puts hotSpot or info in center of scene.

        :param hotSpot: True if hotSpot is added, False if info is added
        :type hotSpot: bool
        """
        self.log.info("Execute method _add_button_to_center")
        if hotSpot:
            button = self.btnHotSpot
        else:
            button = self.btnInfo
        scroll_element_to_center(self.driver, self.log, button())
        buttonSize = button().size
        ac = ActionChains(self.driver)
        time.sleep(3)
        ac.move_to_element_with_offset(button(), buttonSize["width"] / 2,
                                       buttonSize["height"] / 2).perform()
        time.sleep(3)
        ac.click_and_hold().perform()
        tourSize = self.tourImage().size
        time.sleep(3)
        #scroll_element_to_viewPoint_with_selenium(self.driver, self.tourImage())
        scroll_element_to_viewpoint_top(self.log, self.driver,
                                        self.tourImage())
        time.sleep(1)
        move_mouse_to_middle_of_browser(self.log, self.driver)
        time.sleep(1)
        ac.move_to_element_with_offset(self.tourImage(), tourSize["width"] / 2,
                                       tourSize["height"] / 2).perform()
        ac.release().perform()
        time.sleep(1)
        self.log.screenshot("Button is added")
 def save_draft(self):
     scroll_element_to_center(self.driver, self.log, self.inpSaveDraft())
     time.sleep(1)
     self.log.screenshot()
     #self.inpSaveDraft().click()
     self.driver.execute_script("arguments[0].click();",
                                self.inpSaveDraft())
Esempio n. 4
0
    def upload_scenes_windows(self, scenes):
        """
        Upload scenes for windows operating system. Forwarded scenes number and number of scenes
         path folder in Images folder must be the same.

        :param scenes: List of scenes
        :type scenes: list[Scene]
        """
        from pywinauto.application import Application

        self.log.info(
            "Execute method upload_scenes with parameters scenes={}".format(
                scenes))
        imgs = get_images_path(scenes[0].folder)
        self.log.info("Scenes path is: {}".format(imgs))
        scroll_element_to_center(self.driver, self.log, self.btnUpload())
        self.btnUpload().click()
        time.sleep(10)
        dialog_name = ""
        if DriverData.driverName == "Firefox":
            dialog_name = "File Upload"
        elif DriverData.driverName == "Chrome":
            dialog_name = "Open"
        app = Application().connect(title=dialog_name)
        time.sleep(3)
        app.Dialog.ComboBoxEx.Edit.type_keys(imgs)
        self.log.screenshot("Entered path to images", True)
        time.sleep(10)
        app.dlg.Open.click()
        time.sleep(10)
        app.Dialog.ComboBoxEx.Edit.type_keys(get_pictures_string(scenes))
        time.sleep(10)
        app.dlg.Open.click()
        self.log.screenshot("Entered all images", True)
Esempio n. 5
0
    def choose_theme(self, number):
        """
        Choose theme by number [1..4]

        :param number: Ordinal number of shown themes
        :type number: int [1..4]
        """
        self.log.info(
            "Execute method choose_theme with parameter number={}".format(
                number))
        wait_until(lambda: check_if_elem_exist(self.btnChangeTheme),
                   timeout=10)
        scroll_element_to_center(self.driver, self.log, self.btnChangeTheme())
        time.sleep(3)
        self.btnChangeTheme().click()
        wait_until(
            lambda: check_if_elem_exist(lambda: self.imgThemeToSelect(number)),
            timeout=30)
        newTheme = self.imgThemeToSelect(number)
        themeSrc = newTheme.find_element_by_tag_name("img").get_attribute(
            "src")
        newTheme.click()
        wait_until(lambda: "selected" in self.imgThemeToSelect(number).
                   get_attribute("class"),
                   timeout=5)
        self.log.screenshot("Theme is selected")
        self.btnSelectTheme().click()
        wait_until(
            lambda: self.btnChangeTheme().get_attribute("src") == themeSrc,
            timeout=20)
        self.log.screenshot("Theme is updated")
Esempio n. 6
0
 def goTo_hotSpot_center(self):
     """
     Click on goTo in hotspot menu
     """
     self.open_menu_hotSpotOrInfo_center()
     self.log.info("Clicked on hotspot")
     self.btnGoToHotSpot().click()
     scroll_element_to_center(self.driver, self.log, self.tourImage())
     time.sleep(1)
     self.log.screenshot("GoTo hotspot clicked")
     self.wait_scene_load()
     self.log.screenshot("Moved to another scene")
Esempio n. 7
0
 def create_new_tour(self):
     """
     Click on create new tour
     """
     self.log.info("Execute method create_new_tour")
     wait_until(lambda: check_if_elem_exist(self.btnCreateNewTour), timeout=30)
     scroll_element_to_center(self.driver, self.log, self.btnCreateNewTour())
     wait_until(lambda: check_if_elem_exist(self.btnCreateNewTour))
     time.sleep(5)
     self.btnCreateNewTour().click()
     self.log.info("Create new tour button clicked")
     wait_until(lambda: check_if_elem_exist(BasicInformationTour(self.driver).inpTitle),
                timeout=30, errorMessage="Create new tour not opened")
Esempio n. 8
0
    def change_current_scene(self, title):
        """
        Change current scene by clicking on pictures with title.

        :param title: Scene to change to
        :type title: str
        """
        self.log.info(
            "Execute method change_current_scene with title={}".format(title))
        self.wait_scene_load()
        self.driver.find_element_by_xpath(
            "//h5[contains(text(),'{}')]".format(title)).click()
        self.wait_scene_load()
        scroll_element_to_center(self.driver, self.log, self.tourImage())
        self.log.screenshot("Current scene changed to {}".format(title))
    def delete_uploaded_scene(self, title):
        """
        Delete uploaded scenes with title.

        :param title: Title of scene to delete
        :type title: str
        """
        self.log.info(
            "Execute method delete_uploaded_scene with parameter={}".format(
                title))
        numberOfScenesBeforeDelete = len(self.get_uploaded_scenes())
        uploadedScenes = self.driver.find_elements_by_css_selector(
            "div[class^='scence-image col-lg-12']")
        foundScene = False
        for scene in uploadedScenes:
            current_title = scene.find_element_by_css_selector(
                "input[id*='scence-title']").get_attribute("value")
            if current_title == title:
                self.log.info("Delete scene with title={}".format(title))
                scroll_element_to_center(
                    self.driver, self.log,
                    scene.find_element_by_css_selector(
                        "div[class='icon-delete']"))
                scene.find_element_by_css_selector(
                    "div[class='icon-delete']").click()
                wait_until(lambda: check_if_elem_exist(self.btnDeleteSceneOk),
                           timeout=10)
                wait_until(expected_conditions.alert_is_present, timeout=10)
                self.btnDeleteSceneOk()
                self.btnDeleteSceneOk().click()
                try:
                    wait_until(
                        lambda: not check_if_elem_exist(self.btnDeleteSceneOk),
                        timeout=10)
                except Exception as ex:
                    self.btnDeleteSceneOk().click()
                wait_until(
                    lambda: numberOfScenesBeforeDelete - 1 == len(
                        self.get_uploaded_scenes()), 30)
                wait_until(lambda: check_if_elem_exist(
                    UploadScenesTour(self.driver).btnUpload),
                           timeout=30,
                           period=2)
                self.log.screenshot("Scene {} deleted".format(title))
                foundScene = True
                break
        if not foundScene:
            raise Exception("Scene with title {} not found".format(title))
Esempio n. 10
0
 def go_to_log_in(self):
     """
     Click on log in
     """
     self.log.info("Go to log in page")
     if not self.btnLogIn().is_displayed():
         time.sleep(2)
         self.btnOpenMenu().click()
         wait_until(lambda: check_if_elem_exist(self.btnLogInMobile),
                    timeout=20)
         scroll_element_to_center(self.driver, self.log,
                                  self.btnLogInMobile())
         self.btnLogInMobile().click()
     else:
         self.btnLogIn().click()
     time.sleep(1)
Esempio n. 11
0
    def rotate_scene(self,
                     pixels,
                     width,
                     useArrows=True,
                     viewTour=False,
                     up=False,
                     down=False):
        """
        Width is full picture size. Pixels are inside of full width. This method will rotate scene
        so that pixels are on center of scene.

        :param pixels: Move scene to center of this location
        :type pixels: int
        :param width: Full width of scene
        :type width: int
        :return: Info about rotate number and direction. If bool True direction is right, otherwise left.
         Rotate number is number of times to rotate.
        :rtype: bool, int
        """
        self.log.info(
            "Execute method rotate_scene with parameters pixels={}, width={}".
            format(pixels, width))
        scroll_element_to_center(self.driver, self.log, self.tourImage())

        oneMove = int(width / 36)  #36 is number of clicking on rotate for 360
        if width / 2 > pixels:
            #move left
            moveForPixels = width / 2 - pixels
            numberRotate = int(moveForPixels / oneMove)
            rotate = ["left:{}".format(numberRotate)]
            if up != 0:
                rotate.append("up:{}".format(up))
            elif down:
                rotate.append("down:{}".format(down))
            self.rotate2(rotate, useArrows, viewTour)
            return False, numberRotate
        else:
            #move right
            moveForPixels = pixels - width / 2
            numberRotate = int(moveForPixels / oneMove)
            rotate = ["right:{}".format(numberRotate)]
            if up:
                rotate.append("up:1")
            elif down:
                rotate.append("down:3")
            self.rotate2(rotate, useArrows, viewTour)
            return True, numberRotate
Esempio n. 12
0
def move_mouse_to_element(driver, log, element):
    """
    Move mouse with pyautogui library to element

    :param driver:
    :param element:
    """
    scroll_element_to_center(driver, log, element)
    hiddenPixels = driver.execute_script("return window.pageYOffset")

    tabHeight = DriverData.tabHeight
    size = element.size
    y = get_location(
        driver, element)["y"] + size["height"] / 2 - hiddenPixels + tabHeight
    x = get_location(driver, element)["x"] + size["width"] / 2
    pyautogui.moveTo(x, y, duration=1)
    time.sleep(1)
Esempio n. 13
0
 def edit_hotSpot_center(self):
     """"
     Edit hotSpot
     """
     self.log.info("Execute method edit_hotSpot_center")
     self.open_menu_hotSpotOrInfo_center()
     self.btnEditHotSpot().click()
     time.sleep(1)
     self.log.info("Edit hotspot clicked")
     action_chains = ActionChains(self.driver)
     scroll_element_to_center(self.driver, self.log,
                              self.get_hotspot_from_center())
     move_mouse_to_middle_of_browser(self.log, self.driver)
     action_chains.drag_and_drop_by_offset(self.get_hotspot_from_center(),
                                           5, 0).perform()
     time.sleep(1)
     self.log.screenshot("Edit for hotSpot is opened")
Esempio n. 14
0
    def click_on_element(self, func):
        """
        Try to click on element. If another element is on top of this element (ElementClickInterceptedException)
        then scroll_to_element is executed and try to click again

        :param element: Element to click on
        :type element: WebElement
        """
        try:
            scroll_element_to_center(self.driver, self.log, func())
            func().click()
        except ElementClickInterceptedException as ex:
            time.sleep(1)
            #scroll because of sticky-header that is on top of site when we scroll down
            pyautogui.press(Keys.ARROW_UP)
            pyautogui.press(Keys.ARROW_UP)
            time.sleep(1)
            func().click()
Esempio n. 15
0
    def _add_button_to_center_safari(self, hotSpot):
        time.sleep(3)
        self.log.info("Execute method _add_button_to_center")
        if hotSpot:
            button = self.btnHotSpot
        else:
            button = self.btnInfo
        oneScrollPixels = self._get_hotSpot_scroll_pixels(hotSpot)

        scroll_element_to_center(self.driver, self.log, button())
        fromLocation = get_location(self.driver, button())
        toLocation = get_location(self.driver, self.tourImage())

        scrollToBottom = self.driver.execute_script(
            "return window.pageYOffset") + int(
                self.driver.execute_script(
                    "return window.innerHeight")) - fromLocation["y"] - 25
        # if not hotSpot:
        #     scrollToBottom -= 37
        moveFor = toLocation["y"] + self.tourImage().size["height"] / 2 - (
            self.driver.execute_script("return window.pageYOffset") +
            int(self.driver.execute_script("return window.innerHeight"))
        ) + int(self.driver.execute_script("return window.innerHeight") / 2)
        numberOfMoves = int(moveFor / oneScrollPixels)

        wantedX = toLocation["x"] + int(self.tourImage().size["width"] / 2)
        wantedY = toLocation["y"] + int(self.tourImage().size["height"] / 2)

        currentX = fromLocation["x"] + int(button().size["width"] / 2)
        if numberOfMoves % 2 != 0:
            currentX += 10
        currentY = fromLocation["y"] + int(
            button().size["height"] /
            2) + scrollToBottom + oneScrollPixels * numberOfMoves
        x = wantedX - currentX
        y = wantedY - currentY
        time.sleep(1)
        ac = ActionChains(self.driver)
        ac.move_to_element(button()).click_and_hold()

        self.drag_with_hotspot_safari(ac, scrollToBottom, numberOfMoves, x, y)

        ActionChains(self.driver).click().perform()
Esempio n. 16
0
 def edit_info_button_center(self, title, name, url):
     """
     Edit info button on center of tour and puts information.
     """
     self.log.info("Execute method edit_info_button_center with parameters "
                   "title={}, name={}, url={}".format(title, name, url))
     action_chains = ActionChains(self.driver)
     time.sleep(2)
     self.open_menu_hotSpotOrInfo_center()
     time.sleep(2)
     action_chains.click(self.divHotSpotMenu().find_element_by_css_selector(
         "a[onclick*='onInfoEdit']")).perform()
     time.sleep(2)
     scroll_element_to_center(self.driver, self.log,
                              self.get_hotspot_from_center())
     move_mouse_to_middle_of_browser(self.log, self.driver)
     ActionChains(self.driver).drag_and_drop_by_offset(
         self.get_hotspot_from_center(), 5, 0).perform()
     time.sleep(1)
     self._add_info_data(title, name, url, "update")
Esempio n. 17
0
    def _set_hotSpot_goingTo(self, title):
        """
        After hotSpot is moved to scene, chose going to scene.

        :param title: Title of scene for hotSpot to show
        :type title: str
        """
        self.log.info(
            "Execute method _set_hotSpot_goingTo with parameter={}".format(
                title))
        options = self.driver.find_element_by_xpath(
            "//select[@id='select-hotSpots']")
        goingTo = self.driver.find_element_by_xpath(
            "//select[@id='select-hotSpots']/option[text()='{}']".format(
                title))
        scroll_element_to_center(self.driver, self.log, options)
        options.click()
        time.sleep(2)
        goingTo.click()
        time.sleep(2)
Esempio n. 18
0
    def _get_hotSpot_scroll_pixels(self, hotSpot):
        """
        For how many pixels to move hotSpot so that scroll is activated

        :param hotSpot: HotSpot of info button. True if hotSpot.
        :type hotSpot: bool
        :return: Pixels to scroll for
        """
        if hotSpot:
            element = self.btnHotSpot()
        else:
            element = self.btnInfo()
        startHidenPixels = get_hidden_pixels(self.driver)
        scroll_element_to_center(self.driver, self.log, element)
        action_chains = ActionChains(self.driver)
        hiddenPixels = get_hidden_pixels(self.driver)
        fromLocation = get_location(self.driver, element)

        action_chains.move_to_element(element)
        action_chains.click_and_hold()
        scrollFor = self.driver.execute_script(
            "return window.pageYOffset") + int(
                self.driver.execute_script(
                    "return window.innerHeight")) - fromLocation["y"] - 25
        action_chains.move_by_offset(0, scrollFor)
        #action_chains.move_by_offset(10, 0)

        # action_chains.move_by_offset(10, 0)
        # action_chains.move_by_offset(-10, 0)
        action_chains.move_by_offset(0, -scrollFor)
        action_chains.release()
        action_chains.perform()
        hiddenPixelsAfter = get_hidden_pixels(self.driver)
        scrolledPixels = hiddenPixelsAfter - hiddenPixels
        self.driver.execute_script("scroll(0,{})".format(startHidenPixels))
        return scrolledPixels
 def enable_variable_pricing(self):
     scroll_element_to_center(self.driver, self.log,
                              self.inpEnableVariablePricing())
     self.inpEnableVariablePricing().click()
     self.log.screenshot()