Python selenium.webdriver.support.ui.Select() Examples

The following are 30 code examples of selenium.webdriver.support.ui.Select(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module selenium.webdriver.support.ui , or try the search function .
Example #1
Source File: test_transactions.py    From biweeklybudget with GNU Affero General Public License v3.0 7 votes vote down vote up
def test_budg_filter_opts(self, selenium):
        self.get(selenium, self.baseurl + '/transactions')
        budg_filter = Select(selenium.find_element_by_id('budget_filter'))
        # find the options
        opts = []
        for o in budg_filter.options:
            opts.append([o.get_attribute('value'), o.text])
        assert opts == [
            ['None', ''],
            ['7', 'Income (income)'],
            ['1', 'Periodic1'],
            ['2', 'Periodic2'],
            ['3', 'Periodic3 Inactive'],
            ['4', 'Standing1'],
            ['5', 'Standing2'],
            ['6', 'Standing3 Inactive']
        ] 
Example #2
Source File: test_scheduled.py    From biweeklybudget with GNU Affero General Public License v3.0 6 votes vote down vote up
def test_1_modal_from_url(self, base_url, selenium):
        self.baseurl = base_url
        self.get(selenium, base_url + '/scheduled/2')
        modal, title, body = self.get_modal_parts(selenium)
        self.assert_modal_displayed(modal, title, body)
        assert title.text == 'Edit Scheduled Transaction 2'
        assert body.find_element_by_id(
            'sched_frm_id').get_attribute('value') == '2'
        assert body.find_element_by_id(
            'sched_frm_description').get_attribute('value') == 'ST2'
        assert body.find_element_by_id(
            'sched_frm_type_monthly').is_selected()
        assert body.find_element_by_id(
            'sched_frm_type_date').is_selected() is False
        assert body.find_element_by_id(
            'sched_frm_type_per_period').is_selected() is False
        assert body.find_element_by_id(
            'sched_frm_day_of_month').get_attribute('value') == '4'
        assert body.find_element_by_id(
            'sched_frm_amount').get_attribute('value') == '222.22'
        acct_sel = Select(body.find_element_by_id('sched_frm_account'))
        assert acct_sel.first_selected_option.get_attribute('value') == '1'
        budget_sel = Select(body.find_element_by_id('sched_frm_budget'))
        assert budget_sel.first_selected_option.get_attribute('value') == '2'
        assert selenium.find_element_by_id('sched_frm_active').is_selected() 
Example #3
Source File: __init__.py    From ontask_b with MIT License 6 votes vote down vote up
def open_condition(self, cname, xpath=None):
        # Select the right button element
        if not xpath:
            xpath = \
                '//div[@id="condition-set"]' \
                '/div/h5[contains(normalize-space(), "{0}")]' \
                '/../div/button[contains(@class, "js-condition-edit")]'.format(
                    cname
                )

        # Wait for the element to be clickable, and click
        WebDriverWait(self.selenium, 10).until(
            EC.element_to_be_clickable((By.XPATH, xpath))
        )
        self.selenium.find_element_by_xpath(xpath).click()

        # Wait for the modal to open
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_description_text')))
        WebDriverWait(self.selenium, 10).until(
            ElementHasFullOpacity((By.XPATH, '//div[@id="modal-item"]'))
        ) 
Example #4
Source File: features_mt.py    From Semantic-Texual-Similarity-Toolkits with MIT License 6 votes vote down vote up
def reload(self):
        driver = self.driver
        driver.get("http://asiya.cs.upc.edu/demo/asiya_online.php#")
        time.sleep(3)
        driver._switch_to.frame(driver.find_element_by_id("demo-content"))
        elem = Select(driver.find_element_by_id("input"))
        elem.select_by_value("raw")
        elem = driver.find_element_by_id("no_tok")
        elem.click()
        elem = Select(driver.find_element_by_id("srclang"))
        elem.select_by_value("en")
        elem = Select(driver.find_element_by_id("trglang"))
        elem.select_by_value("en")
        elem = Select(driver.find_element_by_id("srccase"))
        elem.select_by_value("ci")
        elem = Select(driver.find_element_by_id("trgcase"))
        elem.select_by_value("ci")
        self.driver = driver 
Example #5
Source File: test_ofx.py    From biweeklybudget with GNU Affero General Public License v3.0 6 votes vote down vote up
def test_filter_opts(self, selenium):
        self.get(selenium, self.baseurl + '/ofx')
        acct_filter = Select(selenium.find_element_by_id('account_filter'))
        # find the options
        opts = []
        for o in acct_filter.options:
            opts.append([o.get_attribute('value'), o.text])
        assert opts == [
            ['None', ''],
            ['1', 'BankOne'],
            ['2', 'BankTwoStale'],
            ['3', 'CreditOne'],
            ['4', 'CreditTwo'],
            ['6', 'DisabledBank'],
            ['5', 'InvestmentOne']
        ] 
Example #6
Source File: features_mt.py    From Semantic-Texual-Similarity-Toolkits with MIT License 6 votes vote down vote up
def __init__(self):
        'stst\resources\linux\chromedriver'
        # cur_dir = os.path.dirname(__file__) # 'stst/features'
        # path = os.path.join(cur_dir, 'resources')
        # print(cur_dir)
        driver = webdriver.Chrome()
        driver.get("http://asiya.cs.upc.edu/demo/asiya_online.php#")
        time.sleep(3)
        driver._switch_to.frame(driver.find_element_by_id("demo-content"))
        elem = Select(driver.find_element_by_id("input"))
        elem.select_by_value("raw")
        elem = driver.find_element_by_id("no_tok")
        elem.click()
        elem = Select(driver.find_element_by_id("srclang"))
        elem.select_by_value("en")
        elem = Select(driver.find_element_by_id("trglang"))
        elem.select_by_value("en")
        elem = Select(driver.find_element_by_id("srccase"))
        elem.select_by_value("ci")
        elem = Select(driver.find_element_by_id("trgcase"))
        elem.select_by_value("ci")

        self.driver = driver 
Example #7
Source File: test_create_and_edit.py    From iguana with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
def test_number_kanbancolumns_for_case_not_default(self):
        driver = self.selenium
        issue = Issue(title="title", kanbancol=KanbanColumn.objects.get(project=self.project, name="Todo"),
                      due_date=str(datetime.date.today()), priority=3, storypoints=2, description="blubber",
                      project=self.project
                      )
        issue.save()
        issue.assignee.add(self.user)

        driver.get("{}{}".format(self.live_server_url, reverse('issue:create',
                                                               kwargs={'project': self.project2.name_short})))
        driver.find_element_by_id("id_title").send_keys("title")
        # assert that 2nd project has one kanban col more
        self.assertEqual(len(Select(driver.find_element_by_id("id_kanbancol")).options), 5)

        # assert that dependsOn now has one entry
        driver.get('{}{}'.format(self.live_server_url, reverse('backlog:backlog',
                                                               kwargs={'project': self.project.name_short}
                                                               )))
        driver.find_element_by_link_text("New issue").click()
        driver.find_element_by_xpath("(//input[@type='search'])[2]").send_keys('\n')
        time.sleep(1)
        self.assertEqual(len(driver.find_elements_by_css_selector('#select2-id_dependsOn-results li')), 1)
        for i in driver.find_elements_by_css_selector('#select2-id_dependsOn-results li'):
            self.assertIn("title", i.text) 
Example #8
Source File: test_create_and_edit.py    From iguana with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
def test_edit_same_settings_as_set(self):
        driver = self.selenium
        issue = Issue(title="title", kanbancol=KanbanColumn.objects.get(project=self.project, name="Todo"),
                      due_date=str(datetime.date.today()), priority=3, storypoints=2, description="blubber",
                      project=self.project
                      )
        issue.save()
        issue.assignee.add(self.user)
        driver.get("{}{}".format(self.live_server_url, reverse('issue:edit',
                                 kwargs={'project': self.project.name_short, 'sqn_i': issue.number})))
        self.assertEqual(len(Select(driver.find_element_by_id("id_kanbancol")).options), 4)

        # issue must not depend on itself
        driver.find_element_by_xpath("(//input[@type='search'])[2]").send_keys('\n')
        time.sleep(1)
        self.assertEqual(len(driver.find_elements_by_css_selector('#select2-id_dependsOn-results li')), 1)
        for i in driver.find_elements_by_css_selector('#select2-id_dependsOn-results li'):
            self.assertEqual(i.text, "No results found") 
Example #9
Source File: __init__.py    From ontask_b with MIT License 6 votes vote down vote up
def create_new_survey_action(self, aname, adesc=''):
        # click on the create action button
        self.selenium.find_element_by_class_name('js-create-action').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_name')))

        # Set the name, description and type of the action
        self.selenium.find_element_by_id('id_name').send_keys(aname)
        desc = self.selenium.find_element_by_id('id_description_text')
        # Select the action type
        select = Select(self.selenium.find_element_by_id('id_action_type'))
        select.select_by_value(models.Action.SURVEY)
        desc.send_keys(adesc)
        desc.send_keys(Keys.RETURN)
        # Wait for the spinner to disappear, and then for the button to be
        # clickable
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, '//*[@id="action-in-editor"]')
            )
        )
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        ) 
Example #10
Source File: WebRunner.py    From PyWebRunner with MIT License 6 votes vote down vote up
def set_select_by_value(self, select, value):
        '''
        Set the selected value of a select element by the value.

        Parameters
        ----------
        select: str or selenium.webdriver.remote.webelement.WebElement
            Any valid CSS selector or a selenium element
        value: str
            The value on the select element option. (Not the visible text)

        '''
        if isinstance(select, str):
            elem = self.get_element(select)
        else:
            elem = select

        sel = Select(elem)
        sel.select_by_value(value) 
Example #11
Source File: WebRunner.py    From PyWebRunner with MIT License 6 votes vote down vote up
def set_select_by_text(self, select, text):
        '''
        Set the selected value of a select element by the visible text.

        Parameters
        ----------
        select: str or selenium.webdriver.remote.webelement.WebElement
            Any valid CSS selector or a selenium element
        text: str
            The visible text in the select element option. (Not the value)

        '''
        if isinstance(select, str):
            elem = self.get_element(select)
        else:
            elem = select

        sel = Select(elem)
        sel.select_by_visible_text(text) 
Example #12
Source File: test_selenium.py    From ckanext-privatedatasets with GNU Affero General Public License v3.0 6 votes vote down vote up
def check_ds_values(self, url, private, searchable, allowed_users, acquire_url):
        driver = self.driver
        driver.get(self.base_url + 'dataset/edit/' + url)
        self.assertEqual('Private' if private else 'Public', Select(driver.find_element_by_id('field-private')).first_selected_option.text)

        if private:
            acquire_url_final = '' if acquire_url is None else acquire_url
            self.assertEqual(acquire_url_final, driver.find_element_by_id('field-acquire_url').get_attribute('value'))
            self.assertEqual('True' if searchable else 'False', Select(driver.find_element_by_id('field-searchable')).first_selected_option.text)

            # Test that the allowed users lists is as expected (order is not important)
            current_users = driver.find_element_by_css_selector('#s2id_field-allowed_users_str > ul.select2-choices').text.split('\n')
            current_users = current_users[0:-1]
            # ''.split('\n') ==> ['']
            # if len(current_users) == 1 and current_users[0] == '':
            #     current_users = []
            # Check the array
            self.assertEqual(len(allowed_users), len(current_users))
            for user in current_users:
                self.assertIn(user, allowed_users)
        else:
            self.assert_fields_disabled(['field-searchable', 'field-allowed_users_str', 'field-acquire_url']) 
Example #13
Source File: __init__.py    From ontask_b with MIT License 6 votes vote down vote up
def create_new_action_out_basic(self, aname, action_type, adesc=''):
        # click on the create action button
        self.selenium.find_element_by_class_name('js-create-action').click()
        WebDriverWait(self.selenium, 10).until(
            EC.presence_of_element_located((By.ID, 'id_name')))

        # Set the name, description and type of the action
        self.selenium.find_element_by_id('id_name').send_keys(aname)
        desc = self.selenium.find_element_by_id('id_description_text')
        # Select the action type
        select = Select(self.selenium.find_element_by_id('id_action_type'))
        select.select_by_value(action_type)
        desc.send_keys(adesc)
        desc.send_keys(Keys.RETURN)
        # Wait for the spinner to disappear, and then for the button to be
        # clickable
        WebDriverWait(self.selenium, 10).until_not(
            EC.visibility_of_element_located((By.ID, 'div-spinner'))
        )
        WebDriverWait(self.selenium, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH, '//*[@id="action-out-editor"]')
            )
        ) 
Example #14
Source File: base.py    From tir with MIT License 6 votes vote down vote up
def select_combo(self, element, option):
        """
        Selects the option on the combobox.

        :param element: Combobox element
        :type element: Beautiful Soup object
        :param option: Option to be selected
        :type option: str

        Usage:

        >>> #Calling the method:
        >>> self.select_combo(element, "Chosen option")
        """
        combo = Select(self.driver.find_element_by_xpath(xpath_soup(element)))
        value = next(iter(filter(lambda x: x.text[0:len(option)] == option, combo.options)), None)

        if value:
            time.sleep(1)
            text_value = value.text
            combo.select_by_visible_text(text_value)
            print(f"Selected value for combo is: {text_value}") 
Example #15
Source File: tests.py    From niji with MIT License 6 votes vote down vote up
def test_stick_to_top_admin(self):
        self.browser.get(self.live_server_url + reverse("niji:index"))
        login(self.browser, 'super', '123')
        self.assertIn("Log out", self.browser.page_source)

        lucky_topic1 = getattr(self, 't%s' % random.randint(1, 50))

        self.browser.get(self.live_server_url+reverse('niji:topic', kwargs={"pk": lucky_topic1.pk}))
        self.browser.find_element_by_class_name('move-topic-up').click()
        up_level = WebDriverWait(
            self.browser, 10
        ).until(
            expected_conditions.presence_of_element_located(
                (By.NAME, 'move-topic-up-level')
            )
        )
        up_level = Select(up_level)
        up_level.select_by_visible_text('1')
        time.sleep(1)
        self.browser.execute_script("$('.modal-confirm').click()")
        self.browser.get(self.live_server_url+reverse('niji:index'))
        first_topic_title = self.browser.find_elements_by_class_name('entry-link')[0].text

        self.assertEqual(first_topic_title, lucky_topic1.title) 
Example #16
Source File: test_foo.py    From TorCMS with MIT License 6 votes vote down vote up
def test_changeinfo():
    '''
       修改个人信息
       '''
    test_login()
    driver.get('{0}/user/changeinfo'.format(site_url))
    driver.find_element_by_id('rawpass').send_keys('131322')
    driver.find_element_by_id('user_email').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_truename').send_keys('giser')
    s1 = Select(driver.find_element_by_id('def_gender'))
    s1.select_by_value("Female")
    driver.find_element_by_id('def_birthday').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_mobile').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_location').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_profile').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_postalcode').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_certificatetype').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_certificate').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_company').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_interest').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_high').send_keys('giser@osgeo.cn')
    driver.find_element_by_id('def_weight').send_keys('giser@osgeo.cn')
    s1 = Select(driver.find_element_by_id('def_bloodtype'))
    s1.select_by_value("B")
    driver.find_element_by_xpath('//button[@class="btn btn-primary"]').click() 
Example #17
Source File: conversations.py    From DeleteFB with MIT License 6 votes vote down vote up
def delete_conversation(driver, convo):
    """
    Deletes a conversation
    """

    actions = ActionChains(driver)

    menu_select = Select(driver.find_element_by_xpath("//select/option[contains(text(), 'Delete')]/.."))

    for i, option in enumerate(menu_select.options):
        if option.text.strip() == "Delete":
            menu_select.select_by_index(i)
            break

    wait_xpath(driver, "//h2[contains(text(), 'Delete conversation')]")
    delete_button = driver.find_element_by_xpath("//a[contains(text(), 'Delete')][@role='button']")
    actions.move_to_element(delete_button).click().perform()

    return 
Example #18
Source File: WebRunner.py    From PyWebRunner with MIT License 5 votes vote down vote up
def get_value(self, selector):
        '''
        Gets value of an element by CSS selector.

        Parameters
        ----------
        selector: str
            A CSS selector to search for. This can be any valid CSS selector.

        Returns
        -------
        str
            The value of a selenium element object.

        '''
        elem = self.get_element(selector)
        if self.driver == 'Gecko':
            # Let's do this the stupid way because Mozilla thinks geckodriver is
            # so incredibly amazing.
            tag_name = elem.tag_name
            if tag_name == 'select':
                select = Select(elem)
                return select.all_selected_options[0].get_attribute('value')
            else:
                return elem.get_attribute('value')
        else:
            return elem.get_attribute('value') 
Example #19
Source File: test_autocomplete_view.py    From djongo with GNU Affero General Public License v3.0 5 votes vote down vote up
def test_select(self):
        from selenium.webdriver.common.keys import Keys
        from selenium.webdriver.support.ui import Select
        self.selenium.get(self.live_server_url + reverse('autocomplete_admin:admin_views_answer_add'))
        elem = self.selenium.find_element_by_css_selector('.select2-selection')
        elem.click()  # Open the autocomplete dropdown.
        results = self.selenium.find_element_by_css_selector('.select2-results')
        self.assertTrue(results.is_displayed())
        option = self.selenium.find_element_by_css_selector('.select2-results__option')
        self.assertEqual(option.text, 'No results found')
        elem.click()  # Close the autocomplete dropdown.
        q1 = Question.objects.create(question='Who am I?')
        Question.objects.bulk_create(Question(question=str(i)) for i in range(PAGINATOR_SIZE + 10))
        elem.click()  # Reopen the dropdown now that some objects exist.
        result_container = self.selenium.find_element_by_css_selector('.select2-results')
        self.assertTrue(result_container.is_displayed())
        results = result_container.find_elements_by_css_selector('.select2-results__option')
        # PAGINATOR_SIZE results and "Loading more results".
        self.assertEqual(len(results), PAGINATOR_SIZE + 1)
        search = self.selenium.find_element_by_css_selector('.select2-search__field')
        # Load next page of results by scrolling to the bottom of the list.
        for _ in range(len(results)):
            search.send_keys(Keys.ARROW_DOWN)
        results = result_container.find_elements_by_css_selector('.select2-results__option')
        # All objects and "Loading more results".
        self.assertEqual(len(results), PAGINATOR_SIZE + 11)
        # Limit the results with the search field.
        search.send_keys('Who')
        results = result_container.find_elements_by_css_selector('.select2-results__option')
        self.assertEqual(len(results), 1)
        # Select the result.
        search.send_keys(Keys.RETURN)
        select = Select(self.selenium.find_element_by_id('id_question'))
        self.assertEqual(select.first_selected_option.get_attribute('value'), str(q1.pk)) 
Example #20
Source File: test_autocomplete_view.py    From djongo with GNU Affero General Public License v3.0 5 votes vote down vote up
def test_select_multiple(self):
        from selenium.webdriver.common.keys import Keys
        from selenium.webdriver.support.ui import Select
        self.selenium.get(self.live_server_url + reverse('autocomplete_admin:admin_views_question_add'))
        elem = self.selenium.find_element_by_css_selector('.select2-selection')
        elem.click()  # Open the autocomplete dropdown.
        results = self.selenium.find_element_by_css_selector('.select2-results')
        self.assertTrue(results.is_displayed())
        option = self.selenium.find_element_by_css_selector('.select2-results__option')
        self.assertEqual(option.text, 'No results found')
        elem.click()  # Close the autocomplete dropdown.
        Question.objects.create(question='Who am I?')
        Question.objects.bulk_create(Question(question=str(i)) for i in range(PAGINATOR_SIZE + 10))
        elem.click()  # Reopen the dropdown now that some objects exist.
        result_container = self.selenium.find_element_by_css_selector('.select2-results')
        self.assertTrue(result_container.is_displayed())
        results = result_container.find_elements_by_css_selector('.select2-results__option')
        self.assertEqual(len(results), PAGINATOR_SIZE + 1)
        search = self.selenium.find_element_by_css_selector('.select2-search__field')
        # Load next page of results by scrolling to the bottom of the list.
        for _ in range(len(results)):
            search.send_keys(Keys.ARROW_DOWN)
        results = result_container.find_elements_by_css_selector('.select2-results__option')
        self.assertEqual(len(results), 31)
        # Limit the results with the search field.
        search.send_keys('Who')
        results = result_container.find_elements_by_css_selector('.select2-results__option')
        self.assertEqual(len(results), 1)
        # Select the result.
        search.send_keys(Keys.RETURN)
        # Reopen the dropdown and add the first result to the selection.
        elem.click()
        search.send_keys(Keys.ARROW_DOWN)
        search.send_keys(Keys.RETURN)
        select = Select(self.selenium.find_element_by_id('id_related_questions'))
        self.assertEqual(len(select.all_selected_options), 2) 
Example #21
Source File: basewebobject.py    From avos with Apache License 2.0 5 votes vote down vote up
def _select_dropdown(self, value, element):
        select = Support.Select(element)
        select.select_by_visible_text(value) 
Example #22
Source File: test_autocomplete_view.py    From djongo with GNU Affero General Public License v3.0 5 votes vote down vote up
def test_select_multiple(self):
        from selenium.webdriver.common.keys import Keys
        from selenium.webdriver.support.ui import Select
        self.selenium.get(self.live_server_url + reverse('autocomplete_admin:admin_views_question_add'))
        elem = self.selenium.find_element_by_css_selector('.select2-selection')
        elem.click()  # Open the autocomplete dropdown.
        results = self.selenium.find_element_by_css_selector('.select2-results')
        self.assertTrue(results.is_displayed())
        option = self.selenium.find_element_by_css_selector('.select2-results__option')
        self.assertEqual(option.text, 'No results found')
        elem.click()  # Close the autocomplete dropdown.
        Question.objects.create(question='Who am I?')
        Question.objects.bulk_create(Question(question=str(i)) for i in range(PAGINATOR_SIZE + 10))
        elem.click()  # Reopen the dropdown now that some objects exist.
        result_container = self.selenium.find_element_by_css_selector('.select2-results')
        self.assertTrue(result_container.is_displayed())
        results = result_container.find_elements_by_css_selector('.select2-results__option')
        self.assertEqual(len(results), PAGINATOR_SIZE + 1)
        search = self.selenium.find_element_by_css_selector('.select2-search__field')
        # Load next page of results by scrolling to the bottom of the list.
        for _ in range(len(results)):
            search.send_keys(Keys.ARROW_DOWN)
        results = result_container.find_elements_by_css_selector('.select2-results__option')
        self.assertEqual(len(results), 31)
        # Limit the results with the search field.
        search.send_keys('Who')
        results = result_container.find_elements_by_css_selector('.select2-results__option')
        self.assertEqual(len(results), 1)
        # Select the result.
        search.send_keys(Keys.RETURN)
        # Reopen the dropdown and add the first result to the selection.
        elem.click()
        search.send_keys(Keys.ARROW_DOWN)
        search.send_keys(Keys.RETURN)
        select = Select(self.selenium.find_element_by_id('id_related_questions'))
        self.assertEqual(len(select.all_selected_options), 2) 
Example #23
Source File: __init__.py    From ontask_b with MIT License 5 votes vote down vote up
def add_column(self,
        col_name,
        col_type,
        col_categories='',
        col_init='',
        index=None):
        # Click on the Add Column -> Regular column
        self.open_add_regular_column()

        # Set the fields
        self.selenium.find_element_by_id('id_name').send_keys(col_name)
        select = Select(self.selenium.find_element_by_id(
            'id_data_type'))
        select.select_by_value(col_type)
        if col_categories:
            self.selenium.find_element_by_id(
                'id_raw_categories').send_keys(col_categories)
        if col_init:
            self.selenium.find_element_by_id(
                'id_initial_value'
            ).send_keys(col_init)
        if index:
            self.selenium.find_element_by_id('id_position').clear()
            self.selenium.find_element_by_id('id_position').send_keys(
                str(index)
            )

        # Click on the Submit button
        self.selenium.find_element_by_xpath(
            '//div[@id="modal-item"]//button[normalize-space()="Add column"]'
        ).click()
        self.wait_close_modal_refresh_table('column-table_previous') 
Example #24
Source File: test_frontend.py    From callisto-core with GNU Affero General Public License v3.0 5 votes vote down vote up
def test_extra_dropdown_persists(self):
        self.element.extra_dropdown.click()
        self.element.wait_for_display()

        self.assertEqual(self.element.dropdown_select.get_attribute("value"), "1")

        select = Select(self.element.dropdown_select)
        select.select_by_value("2")

        self.element.next.click()
        self.element.back.click()

        self.assertEqual(self.element.dropdown_select.get_attribute("value"), "2") 
Example #25
Source File: test_admin.py    From course-discovery with GNU Affero General Public License v3.0 5 votes vote down vote up
def _select_option(self, select_id, option_value):
        select = Select(self.browser.find_element_by_id(select_id))
        select.select_by_value(option_value) 
Example #26
Source File: chrome_tixcraft.py    From tixcraft_bot with Apache License 2.0 5 votes vote down vote up
def tixcraft_ticket_main(url, is_verifyCode_editing):
    form_select = None
    try:
        #form_select = driver.find_element(By.TAG_NAME, 'select')
        form_select = driver.find_element(By.CSS_SELECTOR, '.mobile-select')

        if form_select is not None:
            try:
                #print("get select ticket value:" + Select(form_select).first_selected_option.text)
                if Select(form_select).first_selected_option.text=="0":
                    is_verifyCode_editing = False
            except Exception as exc:
                print("query selected option fail")
                print(exc)
                pass

            if is_verifyCode_editing == False:
                ticket_number_auto_fill(url, form_select)

                # start to input verify code.
                try:
                    #driver.execute_script("$('#TicketForm_verifyCode').focus();")
                    driver.execute_script("document.getElementById(\"TicketForm_verifyCode\").focus();")

                    is_verifyCode_editing = True
                    print("goto is_verifyCode_editing== True")
                except Exception as exc:
                    print(exc)
                    pass
            else:
                #print("is_verifyCode_editing")
                # do nothing here.
                pass

    except Exception as exc:
        print("find select fail")
        pass

    return is_verifyCode_editing 
Example #27
Source File: test_foo.py    From TorCMS with MIT License 5 votes vote down vote up
def test_info_edit():
    '''
        整体测试修改信息。
        '''
    test_login()
    sleep(5)
    driver.get('{0}/info/_edit/928b3'.format(site_url))
    driver.find_element_by_id('title').send_keys('kldfkeji')
    driver.find_element_by_id('tags').send_keys('sfef')
    driver.find_element_by_id('logo').send_keys(
        '/static/upload/b9/b99c9056-90ef-11e6-8e5f-6c0b8492a212_m.jpg')

    s1 = Select(driver.find_element_by_id('tag__record'))
    s1.select_by_value("2")
    s2 = Select(driver.find_element_by_id('tag__derive'))
    s2.select_by_value("1")
    s3 = Select(driver.find_element_by_id('tag__temperal'))
    s3.select_by_value("3")
    s4 = Select(driver.find_element_by_id('tag__spatial'))
    s4.select_by_value("1")
    s5 = Select(driver.find_element_by_id('tag__from_projct'))
    s5.select_by_value("2")
    s6 = Select(driver.find_element_by_id('tag__share_type'))
    s6.select_by_value("1")
    s7 = Select(driver.find_element_by_id('tag__storage'))
    s7.select_by_value("2")
    s8 = Select(driver.find_element_by_id('tag__view_class'))
    s8.select_by_value("1")
    s9 = Select(driver.find_element_by_id('tag__paper_type'))
    s9.select_by_value("2")
    s10 = Select(driver.find_element_by_id('tag__media_type'))
    s10.select_by_value("1")

    # driver.find_element_by_id('cnt_md').send_keys('content')
    # driver.find_element_by_id('memo').send_keys('14')
    driver.find_element_by_id('Button1').click()
    sleep(5) 
Example #28
Source File: test_foo.py    From TorCMS with MIT License 5 votes vote down vote up
def test_info():
    '''
       整体测试添加信息。
       '''

    test_login()
    sleep(5)
    driver.get('{0}/info/_cat_add/8101'.format(site_url))
    driver.find_element_by_id("title").send_keys('kldfkeji')
    driver.find_element_by_id('tags').send_keys('sfef')
    driver.find_element_by_id('logo').send_keys(
        '/static/upload/b9/b99c9056-90ef-11e6-8e5f-6c0b8492a212_m.jpg')
    # driver.find_element_by_xpath("//textarea[@id='cnt_md']").send_keys('coasasdsdnte1131321321513201531302313151nt')

    s1 = Select(driver.find_element_by_id('tag__record'))
    s1.select_by_value("2")
    s2 = Select(driver.find_element_by_id('tag__derive'))
    s2.select_by_value("1")
    s3 = Select(driver.find_element_by_id('tag__temperal'))
    s3.select_by_value("3")
    s4 = Select(driver.find_element_by_id('tag__spatial'))
    s4.select_by_value("1")
    s5 = Select(driver.find_element_by_id('tag__from_projct'))
    s5.select_by_value("2")
    s6 = Select(driver.find_element_by_id('tag__share_type'))
    s6.select_by_value("1")
    s7 = Select(driver.find_element_by_id('tag__storage'))
    s7.select_by_value("2")
    s8 = Select(driver.find_element_by_id('tag__view_class'))
    s8.select_by_value("1")
    s9 = Select(driver.find_element_by_id('tag__paper_type'))
    s9.select_by_value("2")
    s10 = Select(driver.find_element_by_id('tag__media_type'))
    s10.select_by_value("1")

    driver.find_element_by_id('Button1').click()
    sleep(5) 
Example #29
Source File: test_foo.py    From TorCMS with MIT License 5 votes vote down vote up
def test_post_reclass():
    '''
        修改文档大分类
        '''
    test_login()
    sleep(5)
    driver.get('{0}/post/t0000'.format(site_url))
    driver.find_element_by_link_text('Reclassify').click()
    sleep(5)
    kind = Select(driver.find_element_by_id('kcat'))
    kind.select_by_value("9")
    driver.find_element_by_name('pcat0').send_keys('Nature Geographic')
    driver.find_element_by_id('sub1').click() 
Example #30
Source File: __init__.py    From selenium-python-helium with MIT License 5 votes vote down vote up
def find_all_in_curr_frame(self):
		all_cbs_with_a_matching_value = super(
			ComboBoxIdentifiedByDisplayedValue, self
		).find_all_in_curr_frame()
		result = []
		for cb in all_cbs_with_a_matching_value:
			for selected_option in Select(cb.unwrap()).all_selected_options:
				if self.matches.text(selected_option.text, self.search_text):
					result.append(cb)
					break
		return result