Пример #1
0
    def setUpClass(cls):
        #
        # remove all uploaded files
        pla = platform_get()
        pla.get('/ipt/?tab_id=7&subtab_id=1')

        hide_footer(pla)

        common = (
            "//div[starts-with(@id, 'tabs-') and"
            " @name='configuration_file']"
            "//div[starts-with(@id, 'cf_subtabs-') and @name='scenario']")

        clean_all = pla.xpath_finduniq(
            common + "//button[@type='submit' and @name='clean_all']")
        clean_all.click()

        confirm = pla.xpath_finduniq(
            "//div[@class='ui-dialog-buttonset']//button["
            "@type='button' and normalize-space(text())='Yes']")
        confirm.click()

        #
        # populate uploaded file with template
        if _fpath_field_directory:
            if os.path.isdir(_fpath_field_directory):
                shutil.rmtree(_fpath_field_directory)
        replicatetree(os.path.join(
            os.path.dirname(__file__), 'data'), _fpath_field_directory)
Пример #2
0
    def persistent_filter_test(self):
        pla = platform_get()
        # go to test page, tab Fragility
        pla.get('/vulnerability/list?type_of_assessment=1')

        # find LLRS dropdown filter menu
        sel_tag = pla.xpath_finduniq(
            "//form[@name='filter']//select[@id='id_llrs']")
        sel = Select(sel_tag)
        sel.select_by_value("LWAL")

        # find filter button and click it
        filter = pla.xpath_finduniq(
            "//form[@name='filter']//button[@type='submit' and"
            " @value='Filter']")
        filter.click()

        # move to tab vulnerability
        pla.get('/vulnerability/list?type_of_assessment=2')
        pla.waituntil_js(10, ("try { return (window.gem_app_initialized"
                              " == true); } catch (exc) { return false; }"))


        # find again LLRS dropdown filter menu
        sel_tag = pla.xpath_finduniq(
            "//form[@name='filter']//select[@id='id_llrs']")
        sel = Select(sel_tag)

        # retrieve the selected item (that must be equal
        # to the previous selected)
        selected_item = sel.all_selected_options

        # check if the value is the same selected in the previous page
        self.assertEqual(selected_item[0].get_attribute('value'), 'LWAL')
    def click_and_help_simple_test(self):
        pla = platform_get()

        hide_footer()

        first_tab_tag = pla.xpath_finduniq(
            "//li[span[normalize-space(text()) = 'Structural System']]")
        first_tab_tag.click()

        click_and_help_tag = pla.xpath_finduniq(
            "//li[@id='id_help_form']")
        click_and_help_tag.click()

        simple_help = pla.xpath_finduniq(
            "//li[span[normalize-space(text()) = 'Direction X']]")

        # check width / 2, height / 2 of simple_help
        simpl_help_width = simple_help.size['width'] / 2
        simpl_help_height = simple_help.size['height'] / 2

        # click with offset
        action_simple_help = ActionChains(pla.driver)
        action_simple_help.move_to_element_with_offset(
            simple_help, simpl_help_width, simpl_help_height).click().perform()

        pla.select_window_by_name(".*Direction X.*", timeout=5.0,
                                  is_regex=True)
        pla.window_close()
        pla.select_main_window()
Пример #4
0
    def check_empty_cells_test(self):
        pla = platform_get()
        pla.get('/ipt')

        # initially, we are in the exposure tab
        # and the handson table is empty

        # <button id="saveBtnEX" type="button" style="display: block;"
        #     class="btn btn-primary">Convert to NRML</button>

        convert_btn = pla.xpath_finduniq(
            "//div[contains(concat(' ',normalize-space(@class),' '),"
            "' ex_gid ')]//button[@id='convertBtn' and @type='button'"
            " and normalize-space(text())='Convert to NRML']")

        # required to avoiding wrong click on overlapping "About" link
        convert_btn.location_once_scrolled_into_view

        convert_btn.click()

        pla.xpath_finduniq(
            "//div[contains(concat(' ',normalize-space(@class),' '),"
            "' ex_gid ')]//div[@id='outputDiv']//div[@id='validationErrorMsg'"
            " and normalize-space(text())='Validation error:"
            " empty cell at coords (1, 1).']")
Пример #5
0
    def click_and_help_simple_test(self):
        pla = platform_get()

        first_tab_tag = pla.xpath_finduniq(
            "//li[span[normalize-space(text()) = 'Structural System']]")
        first_tab_tag.click()

        click_and_help_tag = pla.xpath_finduniq(
            "//li[@id='id_help_form']")
        click_and_help_tag.click()

        simple_help = pla.xpath_finduniq(
            "//li[span[normalize-space(text()) = 'Direction X']]")

        # check width / 2, height / 2 of simple_help
        simpl_help_width = simple_help.size['width'] / 2
        simpl_help_height = simple_help.size['height'] / 2

        # click with offset
        action_simple_help = ActionChains(pla.driver)
        action_simple_help.move_to_element_with_offset(
            simple_help, simpl_help_width, simpl_help_height).click().perform()

        pla.select_window_by_name(".*Direction X.*", timeout=5.0,
                                  is_regex=True)
        pla.window_close()
        pla.select_main_window()
Пример #6
0
    def taxonomy_full2short_test(self):
        pla = platform_get()
        from openquakeplatform.common.taxonomy import taxonomy_full2short

        failed = 0
        data_path = os.path.join(os.path.dirname(
            sys.modules[self.__module__].__file__), 'data')

        with open(os.path.join(data_path, 'taxonomies.txt')) as f:
            csv_rows = csv.reader(f, delimiter='|')
            for csv_row in csv_rows:
                taxonomy_type = csv_row[0]
                full = csv_row[1]
                short_exp = csv_row[2]

                # if taxonomy_type != gem_taxonomy => continue
                if taxonomy_type != '1':
                    continue
                short = taxonomy_full2short(full)
                if short != short_exp:
                    sys.stderr.write("IN: [%s] OUT: [%s] EXP: [%s]\n" % (
                        full, short, short_exp))
                    failed += 1
                # Uncomment to see tested taxonomies with correct conversion
                # else:
                #     sys.stderr.write("[%s] Ok\n" % short)

        self.assertEqual(failed, 0)
Пример #7
0
    def upload_test(self):
        # clean all files in upload folder
        pla = platform_get()
        pla.get('/ipt/?tab_id=7&subtab_id=1')

        pla.driver.execute_script(
            "window.gem_not_interactive = true;")

        hide_footer(pla)

        common = (
            "//div[starts-with(@id, 'tabs-')"
            " and @name='configuration_file']"
            "//div[starts-with(@id, 'cf_subtabs-') and @name='scenario']")

        clean_all = pla.xpath_finduniq(
            common + "//button[@type='submit' and @name='clean_all']")
        clean_all.click()

        confirm = pla.xpath_finduniq(
            "//div[@class='ui-dialog-buttonset']//button["
            "@type='button' and normalize-space(text())='Yes']")
        confirm.click()

        # show div with upload file
        up_file = os.path.join(os.path.dirname(__file__), 'data',
                               'rupture_file', 'earthquake_rupture_model.xml')

        butt_upload_file = pla.xpath_finduniq(
            "//button[@name='rupture-file-new'"
            " and normalize-space(text())='Upload']")
        # import pdb ; pdb.set_trace()

        time.sleep(8)
        # pla.scroll_into_view(butt_upload_file)
        butt_upload_file.click()

        upload_file = pla.xpath_finduniq(
            common + "//div[@name='rupture-file-new']"
            "//form[@id='file-upload-form' and @name='rupture-file']"
            "//input[@name='file_upload']")

        pla.driver.execute_script(
            "$(arguments[0]).attr('style','visibility:visible;')", upload_file)

        time.sleep(1)

        upload_file.send_keys(up_file)

        upload_file.submit()

        # wait for js upload callback to setup dropdown item properly
        time.sleep(8)

        list_files = Select(pla.xpath_finduniq(
            common + "//div[@name='rupture-file-html']"
            "//select[@name='file_html']"))

        assert list_files.first_selected_option.text == "earthquake_rupture_model.xml"
Пример #8
0
def tag_and_val_get(xpath, times):
    pla = platform_get()

    hide_footer()

    resulte_tag = pla.xpath_finduniq(xpath, times=times)
    resulte_val = resulte_tag.get_attribute("value")
    return (resulte_tag, resulte_val)
Пример #9
0
def hide_footer():

    pla = platform_get()

    footer = pla.xpath_finduniq("//footer")

    # hide
    pla.driver.execute_script(
        "$(arguments[0]).attr('style','display:none;')", footer)
Пример #10
0
    def generated(self):
        pla = platform_get()

        hide_footer()

        col_red = "rgba(255, 223, 191, 1)"
        col_green = "rgba(191, 255, 191, 1)"

        taxonomy_loc = taxonomy
        if taxonomy_loc[-1] == '/':
            taxonomy_loc = taxonomy_loc[0:-1]

        pla.get('/taxtweb/%s' % taxonomy_loc)

        pla.waituntil_js(10, ("try { return (window.gem_pageloaded"
                              " == true); } catch (exc) { return false; }"))

        typeoftax_tag, typeoftax_val = tag_and_val_get(
            "//select[@id='OutTypeCB']", 20)
        typeoftax_sel = Select(typeoftax_tag)
        for i in range(0, 3):
            typeoftax_sel.select_by_index(i)
            resulte_tag, resulte_val = tag_and_val_get(
                "//input[@id='resultE']", 20)
            if resulte_val == taxonomy_loc:
                break
        else:
            self.assertEqual(resulte_val, taxonomy_loc)

        if run_slow:
            time.sleep(1)
            resulte_tag.click()  # Positions the cursor at the end of string
            if len(resulte_val) > 0 and resulte_val[-1] == '/':
                resulte_tag.send_keys(Keys.BACK_SPACE)
                resulte_tag, resulte_val = tag_and_val_get(
                    "//input[@id='resultE']", 20)

            cur = resulte_val
            while len(cur) > 0:
                last = cur[-1]
                resulte_tag.send_keys(Keys.BACK_SPACE)
                resulte_tag, resulte_val = tag_and_val_get(
                    "//input[@id='resultE']", 20)
                resulte_bgcol = resulte_tag.value_of_css_property(
                    'background-color')
                self.assertNotEqual(resulte_bgcol, col_red)

                if last == "/":
                    # check integrity
                    virtual_tag, virtual_val = tag_and_val_get(
                        "//input[@id='resultE_virt']", 20)

                    self.assertEqual(resulte_bgcol, col_green)
                    self.assertEqual(resulte_val, virtual_val)

                if resulte_val == "":
                    break
Пример #11
0
    def isc_test(self):
        pla = platform_get()
        pla.get('/explore')
        pla.wait_new_page("//b[contains(text(), 'Seismic Hazard Data Sets and Models')]",
                          "/explore", strategy="next", timeout=10)

        #  <li>
        #  <a href="/maps/23">
        enter_button = pla.xpath_finduniq(
            "//li/a[@href='/maps/23' and normalize-space(text()) = 'Global "
            "Instrumental Earthquake Catalogue (1900 - 2009)']")
        enter_button.click()
        pla.wait_new_page(enter_button, '/maps/23')

        enter_button = pla.xpath_finduniq(
            "//a[@href='/maps/23/view' and "
            "normalize-space(text()) = 'View Map']")
        enter_button.click()
        pla.wait_new_page(enter_button, '/maps/23/view', timeout=15)

        # <button id="ext-gen159" class=" x-btn-text gxp-icon-getfeatureinfo"
        # type="button">Identify
        enter_button = pla.xpath_finduniq(
            "//button[@type='button' and normalize-space(text())"
            "= 'Identify']", 50)
        enter_button.click()

        action = ActionChains(pla.driver)
        action.move_by_offset(500, 400)
        action.click_and_hold()
        action.move_by_offset(150, 150)
        action.release()
        action.perform()

        time.sleep(3)

        # wait info button will be clicked
        pla.xpath_finduniq(
            "//button[@type='button' and normalize-space(text())"
            "= 'Identify']/../../../../..[contains(concat(' ', @class, ' '),"
            " ' x-btn-pressed ')]", 100)

        tile = pla.xpath_finduniq(
            "//img[contains(@src, 'wms?LAYERS=oqplatform%3Aisc_viewer_measure"
            "&FORMAT=image%2Fpng&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1"
            "&REQUEST=GetMap&STYLES=&TILED=true&SRS=EPSG%3A900913&BBOX="
            "-10018754.17,0,-5009377.085,5009377.085&WIDTH=256&HEIGHT=256')]",
            50)

        action = ActionChains(pla.driver)
        action.move_to_element_with_offset(tile, 107, 115)
        action.click()
        action.perform()

        pla.xpath_finduniq("//div[text() = '1951-03-19T04:23:00']", 50)
Пример #12
0
    def generated(self):
        pla = platform_get()
        col_red = "rgba(255, 223, 191, 1)"
        col_green = "rgba(191, 255, 191, 1)"

        taxonomy_loc = taxonomy
        if taxonomy_loc[-1] == '/':
            taxonomy_loc = taxonomy_loc[0:-1]

        pla.get('/taxtweb/%s' % taxonomy_loc)

        pla.waituntil_js(10, ("try { return (window.gem_pageloaded"
                              " == true); } catch (exc) { return false; }"))

        typeoftax_tag, typeoftax_val = tag_and_val_get(
            "//select[@id='OutTypeCB']", 20)
        typeoftax_sel = Select(typeoftax_tag)
        for i in range(0, 3):
            typeoftax_sel.select_by_index(i)
            resulte_tag, resulte_val = tag_and_val_get(
                "//input[@id='resultE']", 20)
            if resulte_val == taxonomy_loc:
                break
        else:
            self.assertEqual(resulte_val, taxonomy_loc)

        if run_slow:
            time.sleep(1)
            resulte_tag.click()  # Positions the cursor at the end of string
            if len(resulte_val) > 0 and resulte_val[-1] == '/':
                resulte_tag.send_keys(Keys.BACK_SPACE)
                resulte_tag, resulte_val = tag_and_val_get(
                    "//input[@id='resultE']", 20)

            cur = resulte_val
            while len(cur) > 0:
                last = cur[-1]
                resulte_tag.send_keys(Keys.BACK_SPACE)
                resulte_tag, resulte_val = tag_and_val_get(
                    "//input[@id='resultE']", 20)
                resulte_bgcol = resulte_tag.value_of_css_property(
                    'background-color')
                self.assertNotEqual(resulte_bgcol, col_red)

                if last is "/":
                    # check integrity
                    virtual_tag, virtual_val = tag_and_val_get(
                        "//input[@id='resultE_virt']", 20)

                    self.assertEqual(resulte_bgcol, col_green)
                    self.assertEqual(resulte_val, virtual_val)

                if resulte_val == "":
                    break
Пример #13
0
 def setup_class():
     pla = platform_get()
     pla.get('/taxtweb')
     try:
         dontshow_tag = pla.xpath_finduniq(
             "//div[@id='taxtweb_splash']//input[@name='dontshowmeagain']",
             times=10)
         pla.wait_visibility(dontshow_tag)
         dontshow_tag.click()
         close_tag = pla.xpath_finduniq(
             "//div[@id='taxtweb_splash']//button[@name='close_btn']")
         close_tag.click()
     except:
         pass
Пример #14
0
    def sitecond_upload_with_header_test(self):
        homedir = os.path.expanduser('~')
        outfile = os.path.join(homedir, 'Downloads', 'site_model.xml')

        exp_path = os.path.join(os.path.dirname(
            sys.modules[IptExamplesTest.__module__].__file__), 'expected')

        if os.path.isfile(outfile):
            os.unlink(outfile)

        pla = platform_get()
        pla.get('/ipt/?tab_id=6')
        hide_footer(pla)

        common = "//div[%s]//" % class_match('sc_gid')
        filetag = pla.xpath_finduniq(
            common + "input[@type='file'][@id='table_file']")
        # show div with upload file
        up_file = os.path.join(os.path.dirname(__file__), 'data',
                               'site_model', 'upload_with_header.csv')
        filetag.send_keys(up_file)

        convert = pla.xpath_finduniq(
            common + "button[@id='convertBtn']")
        download = pla.xpath_finduniq(
            common + "button[@id='downloadBtn']")

        convert.click()
        for ct in range(0, 20):
            try:
                pla.wait_visibility(download, timeout=0.1)
                break
            except TimeoutError:
                convert.click()
                continue
        else:
            raise TimeoutError

        exp_filename = os.path.join(
            exp_path, "sitecond_upload_with_header_test.xml")

        with codecs.open(exp_filename, 'r', 'utf-8') as exp_file:
            expected = exp_file.read()

        ret_tag = pla.xpath_finduniq(
            common + "textarea[@id='textareasc']")
        ret = ret_tag.get_attribute("value")

        self.assertEqual(ret, expected)
Пример #15
0
    def jasmine_test(self):
        pla = platform_get()
        # go to test page
        pla.get('/vulnerability/test')

        # wait DOM population via async JS
        pla.xpath_finduniq(
            "//div[@class='jasmine_html-reporter']/div"
            "[@class='results']/div[@class='summary']",
            100, 0.1)

        # check the result of tests
        pla.xpath_finduniq(
            "//span[@class='bar passed' and contains"
            "(normalize-space(text()), ', 0 failures')]")
Пример #16
0
    def add_rows_tables_test(self):
        pla = platform_get()
        pla.get('/ipt')

        footer = pla.xpath_finduniq("//footer")

        # hide footer
        pla.driver.execute_script(
            "$(arguments[0]).attr('style','display:none;')", footer)

        # Check add rows for exposure table
        new_row_btn = pla.xpath_finduniq(
            "//button[@name='new_row_add' and @class='btn'"
            "and @data-gem-id='0' and normalize-space(text())='New Row']")

        # Click add row and check if exists new rows
        for row in range(4, 6):
            new_row_btn.click()
            pla.xpath_findfirst(
                "//div[@class='relative']"
                "//span[@class='rowHeader'"
                " and normalize-space(text())='%s']" % row)

        new_table_btn = pla.xpath_finduniq(
            "//button[@id='new_exposuretbl_add'"
            " and normalize-space(text())='Add New Table']")

        new_table_btn.send_keys(Keys.PAGE_DOWN)

        # Click add row and check if exists new rows
        for id_tbl in range(1, 2):
            new_table_btn.click()
            print('id table: %s' % id_tbl)
            new_table_btn = pla.xpath_finduniq(
                "//div[@name='exposuretbl-%s']" % id_tbl)

            # Check add rows for exposure table
            new_row_new_table_btn = pla.xpath_finduniq(
                "//button[@name='new_row_add' and @class='btn'"
                "and @data-gem-id='1' and normalize-space(text())='New Row']")

            # Click add row and check if exists new rows
            for new_table_row in range(4, 6):
                new_row_new_table_btn.click()
                pla.xpath_findfirst(
                    "//div[@class='relative']"
                    "//span[@class='rowHeader'"
                    " and normalize-space(text())='%s']" % new_table_row)
Пример #17
0
    def tutorial_test(self):

        pla = platform_get()

        tutorial_url = '/building-class/tutorial'

        # Redirect page of tutorial
        pla.get(tutorial_url)

        # Check title page tutorial
        pla.xpath_finduniq("//h2[normalize-space(text())='Tutorial']")

        # Check video tutorial
        pla.xpath_finduniq(
            "//iframe[@id='gem-video'"
            " and @src='https://www.youtube.com/embed/bXrvc9Qzie4']")
Пример #18
0
    def setup_class():
        pla = platform_get()
        pla.get('/taxtweb')

        hide_footer()

        try:
            dontshow_tag = pla.xpath_finduniq(
                "//div[@id='taxtweb_splash']//input[@name='dontshowmeagain']",
                times=10)
            pla.wait_visibility(dontshow_tag)
            dontshow_tag.click()
            close_tag = pla.xpath_finduniq(
                "//div[@id='taxtweb_splash']//button[@name='close_btn']")
            close_tag.click()
        except TimeoutError:
            pass
Пример #19
0
    def explanation_test(self):
        pla = platform_get()
        pla.get('/taxtweb/CU+CIP/HBET:1,12')

        hide_footer()

        exp_btn = pla.xpath_finduniq(
            "//a[@id='do_explanation']")
        exp_btn.click()

        time.sleep(2)

        res = pla.xpath_finduniq("//div[@id='explanation']")
        self.assertEqual(res.text,
                         ('Material type: Concrete, unreinforced\n'
                          'Material technology: Cast-in-place concrete\n'
                          'Number of storeys above ground - Range of'
                          ' the number of storeys: between 1 and 12.'))
Пример #20
0
    def generated(self):
        pla = platform_get()
        homedir = os.path.expanduser('~')

        exp_filename = os.path.join(
            exp_path, "example_%d.%s" % (
                tab_id * 1000 + example['exa_id'] * 10 + subtab_id,
                example['sfx']))

        zipfile = ""
        if 'zipfile' in example:
            zipfile = os.path.join(homedir, 'Downloads', example['zipfile'])
            if os.path.exists(zipfile):
                os.remove(zipfile)

        pla.get('/ipt/?tab_id=%d&subtab_id=%d&example_id=%d' % (
            tab_id, example['subtab_id'], example['exa_id']))

        pla.waituntil_js(50, ("try { return (window.gem_example_completed"
                              " == true); } catch (exc) { return false; }"))

        if 'xpath' in example:
            for xpath in example['xpath']:
                ret_tag = pla.xpath_finduniq(xpath, times=20)

            with codecs.open(exp_filename, 'r', 'utf-8') as exp_file:
                expected = exp_file.read()

            ret = ret_tag.get_attribute("value")
            if ret is None:
                ret = ret_tag.get_attribute('innerHTML')
            self.assertEqual(ret, expected)
        elif 'zipfile' in example:
            for t in gen_timeout_poller(5, 0.2):
                if os.path.exists(zipfile):
                    if (os.path.getsize(zipfile) >=
                            os.path.getsize(exp_filename)):
                        break

            self.assertNotEqual(zipfile, "")
            self.assertTrue(zip_diff(exp_filename, zipfile) == 0)
Пример #21
0
    def click_and_help_complex_test(self):
        pla = platform_get()

        hide_footer()

        third_tab_tag = pla.xpath_finduniq(
            "//li[span[normalize-space(text()) = 'Exterior Attributes']]")
        third_tab_tag.click()

        click_and_help_tag = pla.xpath_finduniq(
            "//li[@id='id_help_form']")
        click_and_help_tag.click()

        select_tag = pla.xpath_finduniq(
            "//select[@id='PositionCB']")

        # check width / 2, height / 2 of select_tag
        select_tag_width = select_tag.size['width'] / 2
        select_tag_height = select_tag.size['height'] / 2

        # click with offset
        action_select_tag = ActionChains(pla.driver)
        action_select_tag.move_to_element_with_offset(
            select_tag, select_tag_width, select_tag_height).click().perform()

        item_tag = pla.xpath_finduniq(
            "//div[@id='gem_help_select']/span[normalize-space(text()) = "
            "'Adjoining building(s) on two sides']")

        item_tag_width = item_tag.size['width'] / 2
        item_tag_height = item_tag.size['height'] / 2

        action_item_tag = ActionChains(pla.driver)
        action_item_tag.move_to_element_with_offset(
            item_tag, item_tag_width, item_tag_height).click().perform()

        pla.select_window_by_name(".*Adjoining buildings on two sides.*",
                                  timeout=5.0, is_regex=True)
        pla.window_close()
        pla.select_main_window()
Пример #22
0
    def click_and_help_complex_test(self):
        pla = platform_get()

        third_tab_tag = pla.xpath_finduniq(
            "//li[span[normalize-space(text()) = 'Exterior Attributes']]")
        third_tab_tag.click()

        click_and_help_tag = pla.xpath_finduniq(
            "//li[@id='id_help_form']")
        click_and_help_tag.click()

        select_tag = pla.xpath_finduniq(
            "//select[@id='PositionCB']")

        # check width / 2, height / 2 of select_tag
        select_tag_width = select_tag.size['width'] / 2
        select_tag_height = select_tag.size['height'] / 2

        # click with offset
        action_select_tag = ActionChains(pla.driver)
        action_select_tag.move_to_element_with_offset(
            select_tag, select_tag_width, select_tag_height).click().perform()

        item_tag = pla.xpath_finduniq(
            "//div[@id='gem_help_select']/span[normalize-space(text()) = "
            "'Adjoining building(s) on two sides']")

        item_tag_width = item_tag.size['width'] / 2
        item_tag_height = item_tag.size['height'] / 2

        action_item_tag = ActionChains(pla.driver)
        action_item_tag.move_to_element_with_offset(
            item_tag, item_tag_width, item_tag_height).click().perform()

        pla.select_window_by_name(".*Adjoining buildings on two sides.*",
                                  timeout=5.0, is_regex=True)
        pla.window_close()
        pla.select_main_window()
Пример #23
0
    def taxonomy_test(self):
        pla = platform_get()
        pla.user_add('one', 'one', '*****@*****.**')
        plb = pla.platform_create(user='******', passwd='one')
        plb.init(landing='/vulnerability/list')

        new_func_btn = plb.xpath_finduniq(
            "//li[@class='vuln_menu']/form[@action='/admin/vulnerability/"
            "generalinformation/add/']/button[@type='submit' and "
            "@value='New function']", 300, 1)

        new_func_btn.click()
        plb.wait_new_page(new_func_btn,
                          '/admin/vulnerability/generalinformation/add', timeout=20)

        general_information(plb, "test function from selenium",
                            "Structure specific", "Building", "GEM",
                            "CU+CIP", "taxo_gem_vis", "type_ass",
                            "auth", "art_tit",
                            "conference", "year", "web_link", "gen_comm",
                            "use_case")

        # taxtweb popup
        plb.select_window_by_name("taxtweb - GEM building taxonomy editor")

        try:
            dontshow_tag = plb.xpath_finduniq(
                "//div[@id='taxtweb_splash']//input[@name='dontshowmeagain']",
                times=10)
            plb.wait_visibility(dontshow_tag)
            dontshow_tag.click()
            close_tag = plb.xpath_finduniq(
                "//div[@id='taxtweb_splash']//button[@name='close_btn']")
            close_tag.click()
        # for future inspections if needed
        #except Exception as e:
            # print "EXCEPT HERE ! %s" % type(e)
        except Exception:
            pass

        samedirect = plb.xpath_finduniq("//input[@id='DirectionCB']")
        samedirect.click()

        dir_y = plb.xpath_finduniq("//li[@id='sub1tab_id-2']")
        dir_y.click()

        material_y = plb.xpath_finduniq("//select[@id='MaterialCB12']")
        plb.select_item_set(material_y, "Steel")

        mat_tech_y = plb.xpath_finduniq("//select[@id='MaterialCB22']")
        plb.select_item_set(mat_tech_y, "Hot-rolled steel members")

        mat_prop_y = plb.xpath_finduniq("//select[@id='MaterialCB32']")
        plb.select_item_set(mat_prop_y, "Riveted connections")

        popform = plb.xpath_finduniq("//li[@id='id_populate_form']")
        popform.click()
        time.sleep(1)

        # close popup and return to main window
        plb.windows_reset()

        taxt_view = plb.xpath_finduniq("//input[@id='id_taxonomy_gem_view']")
        self.assertEqual(taxt_view.get_attribute('value'),
                         u'DX/CU+CIP/DY/S+SR+RIV')

        outtype = plb.xpath_finduniq("//select[@id='OutTypeCB']")
        plb.select_item_set(outtype, "Full")

        taxt_view = plb.xpath_finduniq("//input[@id='id_taxonomy_gem_view']")
        self.assertEqual(taxt_view.get_attribute('value'),
                         u'DX+D99/CU+CIP/L99/DY+D99/S+SR+RIV/L99/H99/Y99/OC99/'
                         'BP99/PLF99/IR99/EW99/RSH99+RMT99+R99+RWC99/'
                         'F99+FWC99/FOS99')

        # to be continue ...
        pla.platform_destroy(plb)

        pla.user_del('one')
Пример #24
0
def tag_and_val_get(xpath, times):
    pla = platform_get()
    resulte_tag = pla.xpath_finduniq(xpath, times=times)
    resulte_val = resulte_tag.get_attribute("value")
    return (resulte_tag, resulte_val)
Пример #25
0
def setup_package():
    pla = platform_get()
    pla.init()
Пример #26
0
def div_sub():

    pla = platform_get()

    pla.xpath_finduniq("//div[@name='sub']", TIMEOUT)
Пример #27
0
    def new_classification_test(self):

        # check ip adress and prod installation
        prod = os.getenv("PROD_INSTALL")

        if prod == 'y':
            get_ip = os.getenv("LXC_IP")
        else:
            get_ip = "localhost:8000"

        pla = platform_get()

        survey_url = '/building-class/'

        # Redirect homepage of application
        pla.get(survey_url)

        user_settings = 'http://%s/building-class/user-settings' % get_ip

        print(user_settings)
        print(pla.url)

        if pla.url == user_settings:
            # User setting
            submit_settings = pla.xpath_finduniq(
                "//button[normalize-space(text())='Submit']", TIMEOUT, True)

            # scroll page and found element
            submit_settings.location_once_scrolled_into_view

            submit_settings.click()

        # Select zone
        zone_field = pla.xpath_finduniq(
            "//select[@id='country-id']"
            "/option[normalize-space(text())='French Guiana']", TIMEOUT, True)
        zone_field.click()

        # Click button new classification
        new_classif = pla.xpath_finduniq("//button[@id='new-classification']",
                                         TIMEOUT, True)
        new_classif.click()

        # Choose occupancy healthcare
        check_occupancy = pla.xpath_finduniq(
            "//input[@name='occupancy' "
            "and @type='radio' and @value='healthcare']", TIMEOUT)
        check_occupancy.click()

        # Occupancy next button
        occup_next = pla.xpath_finduniq(
            "//button[@class='occup_next_btn'"
            " and normalize-space(text())='next']", TIMEOUT)
        occup_next.click()

        # Choose material
        check_material = pla.xpath_finduniq(
            "//input[@name='Steel' and @type='checkbox']")
        check_material.click()

        # Choose type of material
        material_type = pla.xpath_finduniq(
            "//input[@name='Cold formed members' and @type='checkbox']",
            TIMEOUT)
        material_type.location_once_scrolled_into_view  # scroll,found element
        material_type.click()

        # Choose type of material
        connection_material = pla.xpath_finduniq(
            "//input[@name='Bolted connection' and @type='checkbox']", TIMEOUT)
        connection_material.location_once_scrolled_into_view
        connection_material.click()

        # # Lateral load resisting system of material
        lateral_material = pla.xpath_finduniq(
            "//input[@name='Dual system' and @type='checkbox']", TIMEOUT)
        lateral_material.location_once_scrolled_into_view
        lateral_material.click()

        # Height material
        height_material = pla.xpath_finduniq(
            "//input[@name='Tall (>12 floors)'"
            " and @type='checkbox']", TIMEOUT, True)
        height_material.click()

        # Irregularities
        irreg_material = pla.xpath_finduniq(
            "//input[@name='Irregular-soft storey' and @type='checkbox']",
            TIMEOUT)
        irreg_material.click()

        # Ductility
        duct_material = pla.xpath_finduniq(
            "//input[@name='High ductility (PGA>0.3g)' and @type='checkbox']")
        duct_material.click()

        # Occupancy save button
        occup_save = pla.xpath_finduniq(
            "//button[@name='save'"
            " and normalize-space(text())='save']", TIMEOUT)
        # occup_save.click()
        occup_save.send_keys(Keys.ENTER)

        time.sleep(5)
Пример #28
0
def setup_package():
    pla = platform_get()
    pla.init(autologin=False)
Пример #29
0
def setup_package():
    pla = platform_get()
    pla.init(autologin=not STANDALONE)