Example #1
0
 def get_crashes_stats(self, session_id, type):
     params = {"session_id": session_id}
     resp = requests.get("{}/monkey/sessionstats".format(get_settings("ReportServer", "host")), params=params)
     with open("crashes-stats-{}.json".format(type), "a") as f:
         data = json.loads(resp.text)
         data["url"] = "{}/#!/top/session.monkey?id={}".format(get_settings("ReportServer", "host"), session_id)
         f.write(json.dumps(data))
Example #2
0
 def login_osm(self):
     self.try_get(Locator.LOGIN_OSM.get()).click()
     self.try_get(Locator.OSM_USERNAME_FIELD.get()).send_keys(
         get_settings("Tests", "osm_user"))
     self.try_get(Locator.OSM_PASSWORD_FIELD.get()).send_keys(
         get_settings("Tests", "osm_pass"))
     self.try_get(Locator.ENTER_OSM_BUTTON.get()).click()
Example #3
0
 def login_osm(self):
     self.try_get(Locator.LOGIN_OSM.get()).click()
     self.try_get_by_xpath(
         "//*[@type='XCUIElementTypeTextField']").send_keys(
             get_settings("Tests", "osm_user"))
     self.try_get_by_xpath(
         "//*[@type='XCUIElementTypeSecureTextField']").send_keys(
             get_settings("Tests", "osm_pass"))
     self.try_get(LocalizedButtons.LOG_IN_BTN.get()).click()
Example #4
0
 def get(self):
     if get_settings("System", "platform") == "Android":
         return "{}:id/{}".format(get_settings("Android", "package"), self.value["Android"])
     else:
         ios_locator = self.value["IOS"]
         if type(ios_locator) != str and ios_locator is not None:
             return ios_locator.get()
         else:
             return ios_locator
Example #5
0
 def sign_in(self):
     self.driver.find_element_by_xpath("//input[@id='username']").send_keys(
         get_settings("Tests", "booking_user"))
     self.driver.find_element_by_xpath("//button[@type='submit']").click()
     self.driver.find_element_by_xpath("//input[@id='password']").send_keys(
         get_settings("Tests", "booking_pass"))
     self.driver.find_element_by_xpath("//button[@type='submit']").click()
     WebDriverWait(self.driver, 30).until(
         EC.visibility_of_element_located(
             (By.XPATH, "//*[contains(@class,'user_name_block')]")))
Example #6
0
 def restart_app(self):
     logging.info("Terminate app")
     self.driver.execute_script(
         "mobile: terminateApp",
         {"bundleId": get_settings("Android", "package")})
     sleep(5)
     logging.info("Activate app")
     self.driver.execute_script(
         "mobile: activateApp",
         {"bundleId": get_settings("Android", "package")})
     sleep(5)
Example #7
0
 def execute_deeplink(self, deeplink):
     self.driver.execute_script(
         "mobile: shell", {
             'command':
             "am force-stop {}".format(get_settings("Android", "package"))
         })
     self.driver.execute_script(
         "mobile:deepLink", {
             "url": deeplink,
             "package": get_settings("Android", "package")
         })
Example #8
0
def return_back_to_mapsme(steps):
    yield
    driver = WebDriverManager.get_instance().driver
    try:
        if get_settings("System", "platform") == "Android":
            driver.execute_script("mobile: shell", {
                'command': "am start {}/com.mapswithme.maps.SplashActivity".format(get_settings("Android", "package"))})
            steps.close_first_time_frame()
        else:
            driver.execute_script("mobile: activateApp", {"bundleId": 'com.my.maps-beta-enterprise'})
            steps.close_first_time_frame()
    except:
        pass
Example #9
0
 def restart_app(self):
     self.driver.execute_script(
         "mobile: shell", {
             'command':
             "am force-stop {}".format(get_settings("Android", "package"))
         })
     sleep(10)
     self.driver.execute_script(
         "mobile: shell", {
             'command':
             "am start {}/com.mapswithme.maps.SplashActivity".format(
                 get_settings("Android", "package"))
         })
     sleep(5)
Example #10
0
 def osm_changes_reset(self):
     yield
     resp = requests.get("https://api.openstreetmap.org/api/0.6/way/261952031")
     xml = ET.XML(resp.text)
     changeset_text = "<osm> <changeset> <tag k=\"created_by\" v=\"MAPS.ME android 9.6.1-Google\"/> <tag k=\"comment\" v=\"Updated a building\"/> <tag k=\"bundle_id\" v=\"com.mapswithme.maps.pro\"/> </changeset></osm>"
     changeset_id = requests.put("https://api.openstreetmap.org/api/0.6/changeset/create",
                                 data=changeset_text,
                                 auth=(get_settings("Tests", "osm_user"), get_settings("Tests", "osm_pass"))).text
     need_tag = [tag for tag in xml.findall("way")[0].findall("tag") if tag.get("k") == "building:levels"][0]
     need_tag.attrib["v"] = '9'
     xml.findall("way")[0].attrib["changeset"] = changeset_id
     str_xml = ET.tostring(xml).decode()
     requests.put("https://api.openstreetmap.org/api/0.6/way/261952031", data=str_xml,
                  auth=(get_settings("Tests", "osm_user"), get_settings("Tests", "osm_pass")))
Example #11
0
 def terminate_taxi_app(self):
     self.driver.execute_script(
         "mobile: shell", {
             'command':
             "am force-stop {}".format(get_settings("Tests",
                                                    "partner_taxi"))
         })
Example #12
0
 def import_bookmark_from_mail(self, new_name):
     self.try_get_by_xpath("//*[@content-desc='{}']".format(
         LocalizedButtons.GMAIL_OPEN_NAV.get())).click()
     self.try_get_by_text(LocalizedButtons.GMAIL_SENT.get()).click()
     b = self.try_get_by_xpath("//*[contains(@content-desc, '{}')]".format(LocalizedButtons.GMAIL_BOOKMARK.get())) or \
         self.try_get_by_text(LocalizedButtons.GMAIL_BOOKMARK.get(), strict=False)
     b.click()
     sleep(10)
     self.try_get_by_xpath(
         "//*[starts-with(@text, 'http://ge0') and contains(@text, {})]".
         format(new_name)).click()
     if self.try_get_by_text(LocalizedButtons.OPEN_WITH.get(),
                             strict=False):
         (self.try_get_by_text("MAPS.ME")
          or self.try_get_by_text("maps.me beta")).click()
         if self.try_get_by_text(LocalizedSettings.ALWAYS.get()):
             self.try_get_by_text(LocalizedSettings.ALWAYS.get()).click()
     sleep(10)
     assert get_settings(
         "Android", "package"
     ) in self.driver.execute_script(
         "mobile: shell", {
             'command':
             "dumpsys window windows | grep -E 'mObscuringWindow|mHoldScreenWindow|mCurrentFocus'"
         })
Example #13
0
 def test_hotels_aid_browser_rich_pp(self, button_locator, main,
                                     download_moscow_map, b_steps,
                                     return_back_to_mapsme,
                                     switch_to_native):
     b_steps.search_booking_hotel(LocalizedButtons.AEROPOLIS_NAME.get())
     b_steps.scroll_down(from_el=b_steps.try_get(Locator.PP_ANCHOR.get()))
     button = b_steps.find_booking_button_on_pp(button_locator)
     assert button
     button.click()
     WebDriverWait(b_steps.driver, 20).until(EC2.web_view_context_enabled())
     contexts = b_steps.driver.contexts
     cons = [x.split("_")[-1] for x in contexts if x != "NATIVE_APP"]
     b_steps.driver.switch_to.context("WEBVIEW_{}".format(cons[-1]))
     WebDriverWait(b_steps.driver, 20).until(EC.url_contains("booking.com"))
     url = b_steps.driver.current_url
     url_params = dict(parse.parse_qsl(parse.urlsplit(url).query))
     logging.info(str(url_params))
     aid = url_params["aid"]
     if get_settings("System", "Platform") == "Android":
         assert aid == "1595466"
     else:
         assert aid == "1595464"
     b_steps.switch_to_native()
     b_steps.close_first_time_frame()
     b_steps.press_back_until_main_page()
Example #14
0
    def test_hotel_online_filter_list_dates(self, main, b_steps):
        b_steps.click_search_button()
        b_steps.click_categories()
        b_steps.choose_category_in_list(LocalizedCategories.HOTEL.get())
        b_steps.try_get(Locator.HOTEL_FILTER.get()).click()
        s_filter = SearchFilter()
        s_filter.check_in().click()

        when = datetime.now() + timedelta(days=31)

        if get_settings("System", "platform") == "IOS":
            from mapsmefr.pageobjects.calendar import IosSystemCalendar as calendar
        else:
            from mapsmefr.pageobjects.calendar import AndroidSystemCalendar as calendar

        calend = calendar()
        calend.choose_date(when)
        calend.click_done()
        sleep(5)
        if b_steps.try_get(LocalizedButtons.SEARCH.get()):
            b_steps.try_get(LocalizedButtons.SEARCH.get()).click()
        sleep(5)

        s_filter.search_button().click()
        sleep(5)
        b_steps.assert_available_hotels_in_search()
Example #15
0
    def create(self, type, build_number=0, device_id=None, options=None):
        logging.info("session opts: {}".format(options))

        info = json.loads(options)
        self.type = type
        self.build_number = build_number
        self.device_id = Device.init_device(device_id).id
        self.time_start = datetime.now()
        self.caused_by = info["started_by"]
        self.upstream_job = info["name"]
        self.upstream_build_number = info["build_number"]
        self.upstream_url = info["url"]
        params = {
            "build_number": self.build_number,
            "time_start": self.time_start,
            "time_end": self.time_end,
            "device_id": self.device_id,
            "type": self.type,
            "caused_by": info["started_by"],
            "upstream_job": info["name"],
            "upstream_build_number": info["build_number"],
            "upstream_url": info["url"],
            "jenkins_job":
            info["jenkins_job"] if "jenkins_job" in info else None,
            "release": info["release"] if "release" in info else None,
            "release_type":
            info["release_type"] if "release_type" in info else None,
            "test_count": self.test_count
        }
        responce = requests.post(self.url, data=params)
        self.id = int(responce.text)
        with open("session.txt", "w") as f:
            f.write("{}#!/top/session.hardware?id={}".format(
                get_settings('ReportServer', 'host'), self.id))
Example #16
0
    def assert_size_and_sublocations(self, country_name, state_name, loc_name):
        self.try_get(Locator.MENU_BUTTON.get()).click()
        self.try_get(Locator.DOWNLOAD_MAPS.get()).click()
        if country_name:
            logging.info("Trying to find {} folder".format(country_name.get()))
            country, _ = self.try_find_map_with_scroll(country_name.get())
            if country:
                logging.info("Folder {} found.".format(country_name.get()))
                country.click()
                if state_name:
                    logging.info("Trying to find {} folder".format(
                        state_name.get()))
                    state, _ = self.try_find_map_with_scroll(state_name.get())
                    if state:
                        logging.info("Folder {} found.".format(
                            state_name.get()))
                        state.click()
        logging.info("Trying to find city {}".format(loc_name.get()))
        city, _ = self.try_find_map_with_scroll(loc_name.get())
        root = self.try_get_by_xpath(
            "//*[@resource-id='{}:id/recycler']".format(
                get_settings("Android", "package")))
        subtitle = root.find_element_by_xpath(
            ".//*[@class='android.widget.RelativeLayout' and .//*[contains(@resource-id, 'name') and @text='{}']]//*[contains(@resource-id, 'subtitle')]"
            .format(loc_name.get()))
        assert len(subtitle.text.split(",")) <= 3

        size = root.find_element_by_xpath(
            ".//*[@class='android.widget.RelativeLayout' and .//*[contains(@resource-id, 'name') and @text='{}']]//*[contains(@resource-id, 'size')]"
            .format(loc_name.get()))

        assert "МБ" in size.text or "MB" in size.text

        self.press_back_until_main_page()
Example #17
0
 def filter_by_city(self):
     if self.driver.context != "NATIVE_APP":
         return self.driver.find_element_by_xpath("//input[@name='city']/preceding-sibling::div/input")
     else:
         if get_settings("System", "platform") == "IOS":
             return self.driver.find_element_by_xpath("//*[@type='XCUIElementTypeTextField'][1]")
         else:
             return self.driver.find_element_by_xpath("//*[@class='android.widget.EditText'][1]")
Example #18
0
def emulate_location_moscow(driver):
    if get_settings("System", "platform") == "Android":
        pass
    else:
        if not WebDriverManager.get_instance().device.emulator:
            system("idevicelocation -u {} 55.7968802 37.537294".format(WebDriverManager.get_instance().device.udid))
        else:
            WebDriverManager.get_instance().driver.set_location(55.7968802, 37.537294, 0)
Example #19
0
 def assert_taxi_opened(self):
     assert get_settings(
         "Tests", "partner_taxi"
     ) in self.driver.execute_script(
         "mobile: shell", {
             'command':
             "dumpsys window windows | grep -E 'mObscuringWindow|mHoldScreenWindow|mCurrentFocus'"
         })
Example #20
0
 def click_more_bookmark(self, name):
     self.try_find_bookmark_with_scroll(name)  # for scrolling purposes
     sleep(1)
     self.try_get_by_xpath(
         "//*[@class='android.widget.RelativeLayout' and .//*[@text='{}']]/*[@resource-id='{}']"
         .format(name,
                 "{}:id/more".format(get_settings("Android",
                                                  "package")))).click()
Example #21
0
 def see_all(self):
     if self.driver.context != "NATIVE_APP":
         return self.driver.find_element_by_xpath("//*[contains(@class, 'ga_see-all')]")
     else:
         if get_settings("System", "platform") == "IOS":
             return self.driver.find_element_by_id(LocalizedButtons.SEE_ALL.get())
         else:
             return self.driver.find_element_by_xpath("//*[@text='{}']".format(LocalizedButtons.SEE_ALL.get()))
Example #22
0
 def filter_by_tag(self):
     if self.driver.context != "NATIVE_APP":
         return self.driver.find_element_by_xpath("//input[@name='q']")
     else:
         if get_settings("System", "platform") == "IOS":
             return self.driver.find_elements_by_xpath("//*[@type='XCUIElementTypeTextField']")[1]
         else:
             return self.driver.find_elements_by_xpath("//*[@class='android.widget.EditText']")[1]
Example #23
0
 def first_eat_popular(self):
     if get_settings("System", "platform") == "IOS":
         return self.driver.find_element_by_xpath(
             "//*[@type='XCUIElementTypeCell' and ./*[@name='{}']]".format(
                 LocalizedButtons.EAT_AND_DRINK.get().upper(
                 ))).find_element_by_id(Locator.POPULAR.get())
     else:
         return self.driver.find_element_by_id("food").find_element_by_id(
             Locator.POPULAR.get())
Example #24
0
 def delete_guide(self, steps):
     if get_settings("System", "platform") == "IOS":
         BottomPanel().bookmarks().click()
         steps.try_get(LocalizedButtons.GUIDES.get().upper()).click()
         sleep(2)
         while steps.try_get("ic24PxMore"):
             steps.try_get("ic24PxMore").click()
             steps.try_get(LocalizedButtons.DELETE.get()).click()
             sleep(2)
Example #25
0
 def __init__(self):
     self.id = None
     self.method = None
     self.name = None
     self.type = None
     self.description = None
     self.markers = None
     self.url = "{}/testitem/refresh".format(
         get_settings('ReportServer', 'host'))
Example #26
0
    def delete_all_groups(self):
        self.press_back_until_main_page()
        self.click_bookmarks()
        self.try_get_by_text(LocalizedButtons.BOOKMARKS.get()).click()
        groups = self.driver.find_elements_by_xpath(
            "//*[@class='android.widget.RelativeLayout' and not(./*[@text='{}'])]/*[@resource-id='{}']"
            .format(LocalizedButtons.MY_BOOKMARKS.get(),
                    "{}:id/more".format(get_settings("Android", "package"))))
        while len(groups) > 0:
            groups[0].click()
            self.try_get_by_text(LocalizedButtons.DELETE.get()).click()
            groups = self.driver.find_elements_by_xpath(
                "//*[@class='android.widget.RelativeLayout' and not(./*[@text='{}'])]/*[@resource-id='{}']"
                .format(
                    LocalizedButtons.MY_BOOKMARKS.get(),
                    "{}:id/more".format(get_settings("Android", "package"))))

        self.press_back_until_main_page()
Example #27
0
 def first_attraction_popular(self):
     if get_settings("System", "platform") == "IOS":
         return self.driver.find_element_by_xpath(
             "//*[@type='XCUIElementTypeCell' and ./*[@name='{}']]".format(
                 LocalizedButtons.ATTRACTIONS.get().upper(
                 ))).find_element_by_id(Locator.POPULAR.get())
     else:
         return self.driver.find_element_by_id(
             "attractions").find_element_by_id(Locator.POPULAR.get())
Example #28
0
    def choose_date(self, when):
        when_day = format_date(when, "dd")
        when_month = format_date(when, "MMMM",
                                 get_settings("Android", "locale"))
        when_year = format_date(when, "yyyy")

        self.choose_day(when_day)
        self.choose_month(when_month)
        self.choose_year(when_year)
Example #29
0
 def init_device(device_id):
     host = get_settings('ReportServer', 'host')
     response = requests.get("{}/device/{}".format(host, device_id))
     info = json.loads(response.text)
     info["server_url"] = host
     if info['platform_name'] == 'Android':
         return AndroidDevice(info)
     else:
         return IOSDevice(info)
Example #30
0
 def start_monkey(self, devID, out_file, acts, appVer):
     if isdir("logs/{}/{}".format(appVer, devID)) == False:
         makedirs("logs/{}/{}".format(appVer, devID))
     if isfile("logs/{}/{}/{}".format(appVer, devID, out_file)) == True:
         remove("logs/{}/{}/{}".format(appVer, devID, out_file))
     pack_name = get_settings("Android", "package")
     system("adb -s {} shell monkey -p {} -v --pct-syskeys 0 {} > logs/{}/{}/{} 2>&1".format(devID, pack_name,
                                                                                             acts, appVer,
                                                                                             devID,
                                                                                             out_file))