Exemplo n.º 1
0
 def action_listbox_select(self, name, value, groupIndex=1):
     '''
     Select a value in listbox.
     :param name: The control's label name
     :param value: The option's text you want to select
     :param groupIndex: The field group the control located in, default is 1
     :return:
     '''
     logger.info('Select %s in listbox %s' % (value, name))
     listbox = select.Select(self.__get_listbox_element(name, groupIndex))
     listbox.select_by_visible_text(value)
Exemplo n.º 2
0
 def select_complete_at(value):
     dropdown = select.Select(
         driver.find_element_by_xpath(
             "//tr[6]/td/div/div/div/div[2]/select"))
     print("Repair to be completed at " + value)
     if value.lower() == "isc":
         dropdown.select_by_value("Yes")
     elif value.lower() == "mdc":
         dropdown.select_by_value("No")
     else:
         print(value + " is not a valid repair completion location")
         raise Exception
Exemplo n.º 3
0
 def cus_code_move(self, driver, cus_code):
     driver.find_element(*self.customerCode_loc).send_keys(cus_code)
     time.sleep(1)
     driver.find_element(*self.customerCode_loc).click()
     time.sleep(1)
     try:
         ActionChains(driver).move_to_element(
             *self.customerCode_loc).perform()
         time.sleep(3)
         select.Select(
             driver.find_element(*self.customerTip_loc)).select_by_index(0)
     except:
         print('客户列表未出现')
Exemplo n.º 4
0
    def updateNormItem():
        driver = webdriver.Firefox()
        driver.get("http://47.98.217.90:9010/")
        driver.find_element_by_id("username").send_keys("admin")
        driver.find_element_by_id("password").send_keys("1")
        driver.find_element_by_class_name("loginbtn").click()

        driver.find_element_by_class_name("m-xs").click()
        proSelect = select.Select(driver.find_element_by_css_selector("[id='trade']"))
        proSelect.select_by_visible_text("测试")
        # driver.find_element_by_css_selector("[class='btn btn-primary btn-sm '],[text='更新子目']").click()
        # driver.find_element_by_css_selector("[class='layui-layer-btn0'],[text='确定']").click()

        driver.find_element_by_id("treeDemo_4_span").click()
Exemplo n.º 5
0
def perform_action(element, action_type, value=None, extra=None):
    return_value = None
    if action_type == "select":
        element = sel.Select(element)
        element.select_by_visible_text(value)
    elif action_type == "click":
        element.click()
    elif action_type == "settext":
        element.send_keys(value)
    elif action_type == "gettext":
        return_value = element.text
    elif action_type == "getattribute":
        return_value = element.get_attribute(value)
    return return_value
Exemplo n.º 6
0
 def __init__(self):
     switchToDefaultFrame()
     switchToContentFrame()
     self.notes_tab = Notes()
     self.details_tab = Details()
     self.number = driver.find_element_by_id(
         "sc_task.number").get_attribute("value")
     self.requestItem = driver.find_element_by_id(
         "sys_display.sc_task.request_item").get_attribute("value")
     self.shortDescription = driver.find_element_by_id(
         "sc_task.short_description").get_attribute("value")
     self.state = select.Select(driver.find_element_by_id('sc_task.state'))
     self.assignedTo = driver.find_element_by_id(
         'sys_display.sc_task.assigned_to').get_attribute("value")
Exemplo n.º 7
0
    def perform_action(self, element, action_type, value=None):
        if action_type == "click":
            element.click(value)

        elif action_type == "send_keys":
            element.send_keys(value)

        elif action_type == "submit":
            element.submit(value)

        elif action_type == "select":
            element = select.Select(element)
            element.select_by_visible_text(value)
        else:
            print("action_type is unknown")
Exemplo n.º 8
0
 def test_something_else(self):
     driver = self.driver
     self.assertEqual("https://office.localhost/admin/interpreters/add",
                      driver.current_url)
     menu = select.Select(driver.find_element_by_id("hat"))
     menu.select_by_visible_text("contract court interpreter")
     xpath = "//option[text()='contract court interpreter']"
     option = driver.find_element_by_xpath(xpath)
     wait = WebDriverWait(driver, 3)
     wait.until(EC.element_to_be_selected(option))
     #script = '$("#interpreter-form").append(`<input name="interpreter[hat]" value="3">`);$("#interpreter-form").submit();'
     #driver.execute_script(script)
     # "/* $('#hat').val(3); */$('body').prepend(`<strong>WTF? hat is now ${$('#hat').val()}</strong>`)");
     #driver.find_element_by_xpath(xpath).click()
     driver.find_element_by_css_selector("input[name='submit']").click()
Exemplo n.º 9
0
    def set_date_time(self, the_date, the_time):
        """Set date/time field.

        Args:
          the_date: A string of the form mm/dd/yyyy
          the_time: A string of the form hh.  E.g., "03", "22", etc.
        """
        date_element = self.find_element_by_css_selector(
            '#datetime-container input[type="text"]')
        self._tester.driver.execute_script(
            'arguments[0].setAttribute("value", "' + the_date + '")',
            date_element)
        time_element = self.find_element_by_css_selector(
            '#datetime-container select')
        select.Select(time_element).select_by_visible_text(the_time)
        return self
Exemplo n.º 10
0
    def perform_action(self):
        current_window = self.driver.current_window_handle
        time.sleep(1)

        file_table_tab = self.driver.find_element_by_xpath(
            ExperimentPage.file_table_tab_xpath)
        file_table_tab.click()

        try:
            selector_elem = self.driver.find_element_by_xpath(
                ExperimentPage.assembly_selector_xpath)
            selector = select.Select(selector_elem)
        except Exception as e:
            print(e)
            exit()

        selected_assembly = self.driver.find_element_by_xpath(
            '//*[@id="tables"]/div/div[1]/div[1]/select/option[starts-with(text(), "{0}")]'
            .format(self.assembly))

        # Forces driver to scroll to the Assembly selector.
        # Forced scrolling is necessary for the Edge webdriver, otherwise it's unable to interact with the selector.
        try:
            self.driver.execute_script("arguments[0].scrollIntoView(false);",
                                       selector_elem)
            selector.select_by_visible_text(selected_assembly.text)
        except Exception as e:
            print(e)
        time.sleep(1)

        for y in self.driver.find_elements_by_tag_name(
                ExperimentPage.all_buttons_tag_name):
            try:
                if y.text == 'Visualize':
                    y.click()
                    print('Opening genome browser')
                    break
            except:
                pass
        time.sleep(1)
        self.driver.switch_to_window(
            [h for h in self.driver.window_handles if h != current_window][0])
        time.sleep(3)
        self.driver.wait.until(
            EC.element_to_be_clickable((By.ID, UCSCGenomeBrowser.zoom_one_id)))
        time.sleep(3)
Exemplo n.º 11
0
    def service_select(self, driver, waybill):

        judge = self.service_is_correct(waybill)
        if judge:
            print u'配送服务正确,不用重新分拣'
            return
        else:
            #   选择正确的配送服务
            try:
                select.Select(driver.find_element(
                    *self.service_loc)).select_by_visible_text(
                        *self.correct_service_name)
            except Exception as e:
                print e
            time.sleep(3)
            #   点击批量确认
            try:
                driver.find_element(*self.send_loc).send_keys(Keys.ENTER)
            except Exception as e:
                print e
            time.sleep(3)
Exemplo n.º 12
0
 def flight_select(self, driver, flight_no):
     try:
         select.Select(driver.find_element(
             *self.flight_loc)).select_by_visible_text(flight_no)
     except Exception as e:
         print e
     time.sleep(3)
     #   检查航空编号、始发港、目的港是否已自动填入值
     try:
         flight_no = driver.find_element(
             *self.flight_no_loc).get_attribute('value')
         departure_port = driver.find_element(
             *self.departure_port_loc).get_attribute('value')
         destination_port = driver.find_element(
             *self.destination_port_loc).get_attribute('value')
         if flight_no != u'' and departure_port != u'' and destination_port != u'':
             print u'航班选择正常'
         else:
             return
     except Exception as e:
         print e
     time.sleep(3)
Exemplo n.º 13
0
    def t1est_003_upmove_process(self):
        # 登录
        po = LoginPage(self.driver)
        po.login_action('admin', '1')
        # 元素显式等待
        locator = (By.CLASS_NAME, 'm-xs')
        element = WebDriverWait(self.driver, 5, 0.5).until(expected_conditions.presence_of_element_located(locator))
        element.click()
        # # 选择专业

        proselect = select.Select(self.driver.find_element_by_css_selector("[id='trade']"))
        proselect.select_by_visible_text("测试")
        # # 选择目录树第一个节点
        self.driver.find_element_by_css_selector("#treeDemo_4_span").click()
        # # 选择节点下的子目
        normtable = self.driver.find_element_by_css_selector("table#dataTable>tbody")
        normlist = normtable.find_elements_by_tag_name("tr")
        for norm in normlist[1:2]:
            element = norm.find_elements_by_tag_name("td")[0]
            action = ActionChains(self.driver)
            doubclick = action.double_click(element)
            doubclick.perform()
            self.driver.find_element_by_link_text("人工").click()
            table = self.driver.find_element_by_css_selector("#wordproce")
            # 通过标签名获取表格中的所有行对象
            sleep(1)
            trlist = table.find_elements_by_tag_name("tr")
            ele = trlist[len(trlist)-1].find_elements_by_tag_name("td")[1]
            name = ele.text
            print(name)
            ele.click()

            self.driver.find_element_by_link_text("上移").click()

            newtable = self.driver.find_element_by_css_selector("#wordproce")
            newtrlist = newtable.find_elements_by_tag_name("tr")
            ele1 = newtrlist[len(newtrlist) - 2].find_elements_by_tag_name("td")[1]
            name1 = ele1.text
            print(name1)
Exemplo n.º 14
0
    def create_test_data(self):
        pet_params = '?name=Doggy&breed=Pug&age=1'
        veterinary_physician_params = '?username=veterinary_physician&first_name=Dr&middle_name=Veterinary&last_name=Physician&[email protected]'

        with self.wait_for_page_load():
            self.selenium.get(
                '%s%s%s%s' % (self.live_server_url, self.ADD_APPOINTMENT_URI,
                              'create_test_vet/', veterinary_physician_params))

        with self.wait_for_page_load():
            self.selenium.get('%s%s%s%s' %
                              (self.live_server_url, self.ADD_APPOINTMENT_URI,
                               'create_test_pet/', pet_params))

        with self.wait_for_page_load():
            self.selenium.get('%s%s' %
                              (self.live_server_url, self.ADD_APPOINTMENT_URI))

            vet_index = 0
            pet_index = 0

            submit_button = self.selenium.find_element_by_id(
                'submit-id-submit')
            pet_name_field = self.selenium.find_element_by_id('id_pet_name')
            pet_option_fields = pet_name_field.find_elements_by_tag_name(
                'option')
            pet_description_field = self.selenium.find_element_by_id(
                'id_pet_description')
            visit_schedule_field = self.selenium.find_element_by_id(
                'id_visit_schedule')
            visit_description_field = self.selenium.find_element_by_id(
                'id_visit_description')
            veterinary_physician_field = self.selenium.find_element_by_id(
                'id_veterinary_physician')
            vet_option_fields = veterinary_physician_field.find_elements_by_tag_name(
                'option')

            for i, option in enumerate(vet_option_fields):
                if (option.get_attribute('selected') is None):
                    vet_index = i

            for i, option in enumerate(pet_option_fields):
                if (option.get_attribute('selected') is None):
                    pet_index = i

            vet_select_box = select.Select(veterinary_physician_field)
            vet_select_box.select_by_value(
                vet_option_fields[vet_index].get_attribute('value'))

            pet_select_box = select.Select(pet_name_field)
            pet_select_box.select_by_value(
                pet_option_fields[pet_index].get_attribute('value'))

            current_datetime = format(datetime.now() + timedelta(hours=25),
                                      '%m/%d/%Y %I:%M %p')

            actions = ActionChains(self.selenium)
            actions.send_keys_to_element(pet_description_field,
                                         'Siberian Husky')
            actions.send_keys_to_element(visit_schedule_field,
                                         current_datetime)
            actions.send_keys_to_element(visit_description_field, 'Checkup')
            actions.click(submit_button)
            actions.perform()

        with self.wait_for_page_load():
            self.selenium.get(
                '%s%s' % (self.live_server_url, self.VIEW_APPOINTMENTS_URI))

        return {'scheduled_visit': current_datetime}
Exemplo n.º 15
0
 def site_select(self, driver, site):
     try:
         select.Select(driver.find_element(*self.site_loc)).select_by_visible_text(site)
     except Exception as e:
         print e
     time.sleep(5)
Exemplo n.º 16
0
xpath_operator = "//select[@name='operator']"
xpath_prepaid = "//span[contains(text(),'Prepaid')]/preceding-sibling::input"
xpath_circle = "//select[@name='circle']"
xpath_proceed_button = "//div/button[contains(text(),'Proceed')]"
xpath_amount = "//div/input[@name='amount']"

driver = webdriver.Chrome(executable_path="./drivers/chromedriver.exe")
driver.maximize_window()
driver.implicitly_wait(10)

driver.get("https://www.freecharge.in/")

element = driver.find_element_by_name(name_mobile_number)
element.send_keys("8421835355")

element = driver.find_element_by_xpath(xpath_prepaid)
element.click()

element = driver.find_element_by_xpath(xpath_operator)
sel = select.Select(element)
sel.select_by_visible_text("Airtel")

element = driver.find_element_by_xpath(xpath_circle)
sel = select.Select(element)
sel.select_by_visible_text("Maharashtra")

element = driver.find_element_by_xpath(xpath_proceed_button)
element.click()

element = driver.find_element_by_xpath(xpath_amount)
element.send_keys("35")
Exemplo n.º 17
0
 def set_questions_give_feedback(self):
     select.Select(self.find_element_by_name(
         'scored')).select_by_visible_text('Questions only give feedback')
     return self
Exemplo n.º 18
0
 def set_questions_are_scored(self):
     select.Select(self.find_element_by_name(
         'scored')).select_by_visible_text('Questions are scored')
     return self
Exemplo n.º 19
0
 def set_post_assessment(self, assessment_name):
     select.Select(self.find_element_by_name(
         'post_assessment')).select_by_visible_text(assessment_name)
     return self
 def select_province(self, province):
     """选择省份"""
     sel = self.driver.find_element(*PortalObject.provinceSelect)
     select.Select(sel).select_by_value(province)
     time.sleep(1)
Exemplo n.º 21
0
 def set_availability(self, value):
     select_elt = self.find_element_by_id(
         'multi-course-select-availability')
     select.Select(select_elt).select_by_visible_text(value)
     return self
Exemplo n.º 22
0
short_descr = fake.sentence(nb_words=6, variable_nb_words=True, ext_word_list=None)
descr = fake.text()
title = name
meta = short_descr
SKU = fake.bothify(text="###-?##-##?", letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
GTN = fake.bothify(text="#############", letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
TARIC = fake.bothify(text="######## ## ####", letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

wd.find_element_by_css_selector("input[name='name[en]']").send_keys(name)
wd.find_element_by_css_selector("input[name='code']").send_keys(code)

elements = wd.find_elements_by_css_selector("input[name='categories[]']")
for element in elements:
    element.click()

select.Select(wd.find_element_by_css_selector("select[name='default_category_id']")).select_by_value('2')

wd.find_element_by_css_selector("input[value='1-3']").click()
wd.find_element_by_css_selector("input[name=quantity]").clear()
wd.find_element_by_css_selector("input[name=quantity]").send_keys("12345,44")
wd.find_element_by_css_selector("input[name='new_images[]']").send_keys(os.getcwd()+"/duck.jpg")

wd.find_element_by_xpath('//*[@id="content"]/form/div/ul/li[2]/a').click()
time.sleep(1)
select.Select(wd.find_element_by_css_selector("select[name='manufacturer_id']")).select_by_value('1')
wd.find_element_by_css_selector("input[name=keywords]").send_keys(keywords)
wd.find_element_by_css_selector("input[name='short_description[en]']").send_keys(short_descr)
wd.execute_script("document.querySelector('div.trumbowyg-editor').innerText = arguments[0]", descr)
wd.find_element_by_css_selector("input[name='head_title[en]']").send_keys(title)
wd.find_element_by_css_selector("input[name='meta_description[en]']").send_keys(meta)
 def select_city(self, city):
     """选择市"""
     sel = self.driver.find_element(*PortalObject.citySelect)
     select.Select(sel).select_by_value(city)
     time.sleep(1)
Exemplo n.º 24
0
 def Select(self, target, label):
     element = self.WaitUntil(self.GetVisibleElement, target)
     select.Select(element).select_by_visible_text(label)
# 28.05.2018 -- спустя ~ 1,5 месяца скрипт не работает
# 28.05.2018 -- восстановил работоспособность. ничего не менял, xpath сделал такие же как и в самом начале.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import select
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait

path = 'C:\SeleniumDrivers\Chrome\chromedriver.exe'
driver = webdriver.Chrome(path)
driver.get("https://www.avito.ru/saransk")
elem = driver.find_element_by_name("category_id")
elem.click()
elem2 = select.Select(elem).select_by_visible_text("Квартиры")
elem3 = driver.find_element_by_id("directions")
elem3.click()


def search(keys):
    query = driver.find_element_by_id("search")
    query.clear()
    query.send_keys(keys)
    query.send_keys(Keys.RETURN)


def open_dropdowns(xpath):
    global dropdown, dropdown2
    WebDriverWait(driver,
                  8).until(ec.element_to_be_clickable((By.XPATH, xpath)))
# получение списка хендлов
handles_list = driver.window_handles
spys_window = handles_list[0]
hide_window = handles_list[1]

# переключение на второе окно, переход на hidemy, возврат на spys.one
driver.switch_to.window(hide_window)
driver.get("https://hidemy.name/ru/proxy-checker/")
form = driver.find_element_by_id("f_in")
driver.switch_to.window(spys_window)

# сортировка по SOCKS5
sort_socks5 = driver.find_element_by_id("xf5")
sort_socks5.click()
select.Select(sort_socks5).select_by_value("2")

# отображение всех прокси на странице
sort_all = driver.find_element_by_id("xpp")
sort_all.click()
select.Select(sort_all).select_by_value("5")

# теперь парсим строки, выбираем сервера со 100% аптаймом
# если аптайм сервака == 100%, то выводим на печать ip:port, страну, аптайм сервака + (количество проверок)
# "//tbody/tr[4]" - "//tbody/tr[503]" -- столько всего строк

for str_count in range(4, 503):
    # локатор аптайма
    percents_xpath = "//tr[" + str(str_count) + "]/td[8]"
    percent_elem = driver.find_element_by_xpath(percents_xpath)
Exemplo n.º 27
0
 def select_student_group(self, option_text):
     select.Select(self.find_element_by_name(
         'student_group')).select_by_visible_text(option_text)
     return self
Exemplo n.º 28
0
 def set_status(self, status):
     select.Select(self.find_element_by_name(
         'is_draft')).select_by_visible_text(status)
     return self
Exemplo n.º 29
0
 def GetSelectedLabel(self, target):
     element = self.WaitUntil(self.GetVisibleElement, target)
     return select.Select(element).first_selected_option.text.strip()
Exemplo n.º 30
0
def country_select(i):
    country_filter = driver.find_element_by_id("frmsearchFilter-country")
    select.Select(country_filter).select_by_visible_text(i)