Example #1
0
def first(url):
    driver = webdriver.Chrome(chromedriver)
    driver.get(url)
    driver.find_element_by_id('ctl00_cphBody_mdsMessageType_imgSelect').click()
    sleep(3)
    driver.switch_to.frame(0)
    driver.find_element_by_xpath("//li[9]/div/span[2]").click()
    driver.find_element_by_xpath("//li[9]/ul/li/div/span[2]").click()
    driver.switch_to.default_content()
    element = driver.find_element_by_id(
        "ctl00_cphBody_cldrBeginDate_tbSelectedDate")
    actions = ActionChains(driver)
    actions.double_click(element).perform()
    driver.find_element_by_id(
        "ctl00_cphBody_cldrBeginDate_tbSelectedDate").send_keys(date_begin)
    element = driver.find_element_by_xpath("//td[5]/table/tbody/tr/td/input")
    actions = ActionChains(driver)
    actions.double_click(element).perform()
    driver.find_element_by_id(
        "ctl00_cphBody_cldrEndDate_tbSelectedDate").send_keys(date_end)
    dropdown = driver.find_element_by_id("ctl00_cphBody_ucRegion_ddlBoundList")
    dropdown.find_element_by_xpath("//option[. = 'г. Москва']").click()
    driver.find_element_by_id("ctl00_cphBody_ibMessagesSearch").click()
    sleep(2)
    r = driver.find_elements_by_xpath(
        "//a[contains(text(),'Объявление о проведении торгов')]")
    for i in r:
        a = i.get_attribute('href')
        urls.append(str(a))
Example #2
0
    def DoubleClick(cls):
        ''' 左键点击2次 '''

        element = cls._element()
        action = ActionChains(Web.driver)
        action.double_click(element)
        action.perform()
Example #3
0
    def revert_messages(self, num_posts):
        # messages = browser.find_elements_by_xpath("//div[@class='Igw0E  Xf6Yq  eGOV_ ybXk5 _4EzTm']")

        messages = self.browser.find_elements_by_css_selector(
            constants.paths["messages"])[::-1]

        count = 0
        for m in messages:
            if count == num_posts:
                break
            count += 1

            constants.sleep_rand()
            self.browser.execute_script("arguments[0].scrollIntoView(true)", m)

            # like_message = m.find_element_by_xpath(constants.paths["like_message"])
            # profile = m.find_element_by_xpath(constants.paths["profile"])

            # self.__like_comment(profile)

            # actions = ActionChains(self.browser)
            # actions.double_click(like_message).perform()

            try:

                like_message = m.find_element_by_xpath(
                    constants.paths["like_message"])
                profile = m.find_element_by_xpath(constants.paths["profile"])

                self.__like_comment(profile)

                actions = ActionChains(self.browser)
                actions.double_click(like_message).perform()
            except:
                print("skipping non-emoji message")
class baseClass():
    def feach_browser(self):
        self.driver = webdriver.Chrome(executable_path=r"C:\Users\sony\PycharmProjects\SeleniumTestProj\Drivers\chromedriver.exe")
        return self.driver
    def feach_url(self,url):
        self.driver.get(url)
    def current_url(self):
        c_url=self.driver.current_url
        return c_url
    def url_title(self):
        url_title=self.driver.title
        return url_title
    def insert_value(self,w_element,value):
        w_element.send_keys(value)
    def we_click(self,w_element):
        w_element.click()
    def mouseOver(self,w_element):
        self.ac = ActionChains(self.driver)
        self.ac.move_to_element(w_element).perform()
    def click(self):
        self.ac.click().perform()
    def r_click(self,w_element):
        self.ac.context_click(w_element).perform()
    def double_click(self,w_element):
        self.ac.double_click(w_element).perform()
    def print_capital(self,key_name,input_txt):
        self.ac.key_down(Keys.SHIFT, key_name).send_keys(input_txt).key_up(Keys.SHIFT, key_name).perform()
    def drag_and_drop(self,src,dest):
        self.ac.drag_and_drop(src,dest).perform()
    def click_and_hold(self,src,dest):
        self.ac.click_and_hold(src).release(dest)
    def switch_to_alert(self):
        self.alerts=self.driver.switch_to.alert
    def switch_to_frame(self,frame_id):
        self.frames=self.driver.switch_to.frame(frame_id)
    def switch_to_window(self,win_id):
        self.windows=self.driver.switch_to.window(win_id)
    def switch_to_parent(self):
        self.driver.switch_to.default_content()
    def alert_accept(self):
        self.alerts.accept()
    def alert_dismiss(self):
        self.alerts.dismiss()
    def send_text_to_alert(self,alert_text):
        self.alerts.send_keys(alert_text)
    def get_text_frm_alert(self):
        alrt_txt=self.alerts.text
        return alrt_txt
    def current_window(self):
        par_id=self.driver.current_window_handle
        return par_id
    def all_open_windows(self):
        all_id=self.driver.window_handles
        return all_id
    def close_current_window(self):
        self.driver.close()
    def close_all_driver_win(self):
        self.driver.quit()
    def sleep_mtd(self,sec):
        time.sleep(sec)
Example #5
0
 def test_ghwh(driver):
     get_new_window(driver)
     driver.find_element_by_link_text('挂号管理').click()
     driver.find_element_by_link_text('挂号管理').click()
     sleep(2)
     driver.find_element_by_link_text('挂号维护').click()
     get_new_window(driver)
     sleep(2)
     ghwh = driver.switch_to.frame(1)
     # driver.switch_to.frame('baidu)
     ghwh_mzh = driver.find_element_by_id('CMZH')
     actions = ActionChains(driver)
     actions.move_to_element(ghwh_mzh)
     actions.double_click()
     actions.perform()
     sleep(3)
     driver.switch_to.default_content()
     mzh_frame = driver.find_element_by_xpath(
         '//*[@id="layui-layer-iframe2"]')
     driver.switch_to.frame(mzh_frame)
     # filter--挂号维护-门诊号
     sleep(2)
     driver.find_element_by_id('filter').send_keys('2001000062')
     sleep(3)
     # 检索门诊号按钮
     driver.find_element_by_xpath('//*[@id="query_btn"]').click()
     sleep(1)
     driver.switch_to.default_content()
     sleep(2)
     # 点击确定门诊号按钮
     driver.find_element_by_xpath(
         '//*[@id="layui-layer2"]/div[3]/a[1]').click()
    def send_double_click_actions(self,
                                  driver,
                                  myxpath=None,
                                  index_location=0):
        xElements = None
        xElement = None

        try:
            xElements = driver.find_elements_by_xpath(myxpath)
        except Exception as e01:
            pass

        try:
            xElement = xElements[int(index_location)]
        except Exception as e02:
            pass

        try:
            action = ActionChains(driver)
            action.double_click(on_element=xElement)
            action.perform()

        except Exception as e03:
            pass

        return driver
Example #7
0
 def move_to_element_with_offset_and_click(self, loc=None, ele=None, strict=True, xoffset=0, yoffset=0,
                                           action='click'):
     if not (loc or ele):
         LOG_ERROR('loc: {}, ele: {}, 请至少输入一个有效参数!'.format(loc, ele))
     else:
         if not ele:
             ele = self.find_element(loc, strict=strict)
     if ele:
         action_select = ['click', 'double_click', 'context_click']
         if action not in action_select:
             LOG_DEBUG('action: {}参数错误, 可选参数为: {}'.format(action, action_select))
         try:
             self.driver.execute_script("arguments[0].scrollIntoView();", ele)
             LOG_DEBUG('移动到坐标 {}'.format(ele.location))
             actions = ActionChains(self.driver)
             LOG_DEBUG('移动当前坐标的相对坐标 x: {}, y: {}, 点击坐标'.format(xoffset, yoffset))
             actions.move_to_element_with_offset(ele, xoffset, yoffset)
             if action == 'click':
                 actions.click()
             elif action == 'double_click':
                 actions.double_click()
             elif action == 'context_click':
                 actions.context_click()
             else:
                 pass
             actions.perform()
         except Exception as e:
             LOG_DEBUG('移动坐标失败: {}'.format(e))
def double_click(dsk_session: WebDriver, element: WebElement):
    """
    does double click on supplied element
    """
    actions = ActionChains(dsk_session)
    actions.move_to_element(element)
    actions.double_click(element).perform()
Example #9
0
class Print():
    def __init__(self, driver):
        self.action_chains = ActionChains(driver)

    def work(self, content, driver):
        try:
            driver.find_element_by_xpath('//td/input[@name="fphm"]').clear()
        except Exception as e:
            input_check = driver.find_element_by_xpath(
                '//a[@href="/SKServer/zzp/fpcx.do?target=navTab&rel=zzp_fpcx_nav"]'
            )  #专票查询
            self.action_chains.double_click(input_check).perform()
            time.sleep(1)
            fpnum_input = driver.find_element_by_xpath(
                '//td/input[@name="fphm"]')
            fpnum_input.send_keys(content)
            driver.find_element_by_id('cx').click()
            driver.find_element_by_xpath(
                '//div[@class="gridTbody"]//div[contains(text(),{})]'.format(
                    content)).click()
            driver.find_element_by_id('dy').click()
            # time.sleep(10)
        else:
            fpnum_input = driver.find_element_by_xpath(
                '//td/input[@name="fphm"]')
            fpnum_input.send_keys(content)
            driver.find_element_by_id('cx').click()
            driver.find_element_by_xpath(
                '//div[@class="gridTbody"]//div[contains(text(),{})]'.format(
                    content)).click()
            driver.find_element_by_id('dy').click()
Example #10
0
    def double_click(self, element):
        '''双击操作'''
        action_chains = ActionChains(self.browser)
        action_chains.double_click(element).perform()

        #def up_load_file(self,element,filepath):
        elemnt_value = self.get_element()
Example #11
0
class ShuiKong:
    def __init__(self):
        global driver
        self.action_chains = ActionChains(driver)
    def work(self,content):
        driver.find_element_by_xpath('//a[@href="/SKServer/zzspp_spbm/init.do?target=navTab&rel=zzspp_zsfpkj_nav"]').click()#普票
        driver.find_element_by_xpath('//button[@id="xz"]').click()#新增按钮
        input_window = driver.find_element_by_xpath('//input[@id="spmc_1"]')#选择货物或应税劳务名称
        self.action_chains.double_click(input_window).perform()
        time.sleep(1)
        commodity_name  = content[0]
        input_window2 = driver.find_element_by_xpath('//tbody/tr[@target="slt_objId"]//td/div[contains(text(),"{}")]'.format(commodity_name))#根据模板选择第一页对应商品名称(暂时)
        self.action_chains.double_click(input_window2).perform()
        name_input = driver.find_element_by_id('ghdwmc')
        id_input = driver.find_element_by_id('ghdwdm')
        address_input = driver.find_element_by_id('ghdwdzdh')
        bank_input = driver.find_element_by_id('ghdwyhzh')
        unit_pricr_input = driver.find_element_by_id('spdj_1')
        amount_input = driver.find_element_by_id('je_1')
        remark_input = driver.find_element_by_id('bz')
        name_input.send_keys(content[1])
        id_input.send_keys(content[2])
        address_input.send_keys(content[3])
        bank_input.send_keys(content[4])
        unit_pricr_input.send_keys(content[5])
        amount_input.send_keys(content[6])
        remark_input.send_keys(content[7])
        driver.find_element_by_id('fhr').clear()
        driver.find_element_by_id('fhr').send_keys('{}'.format(str(content[8])))#复核人
        time.sleep(1)
        driver.find_element_by_id('kj').click()
        time.sleep(2)
Example #12
0
 def scroll(self, key='end', loc=None, ele=None, strict=False, position=None, action='click'):
     key_select = ['end', 'home', 'page_up', 'page_down']
     if key not in key_select:
         LOG_ERROR('参数key: {}输入错误, 可选有效参数为: {}'.format(key, key_select))
     key_map = {
         'end': Keys.END,
         'home': Keys.HOME,
         'page_up': Keys.PAGE_UP,
         'page_down': Keys.PAGE_DOWN
     }
     if loc or ele:
         self.move_to_element_and_click(loc=loc, ele=ele, strict=strict, action=action)
     elif position:
         self.move_by_offset_and_click(xoffset=position[0], yoffset=position[1], action=action)
     else:
         actions = ActionChains(self.driver)
         if action == 'click':
             actions.click()
         elif action == 'double_click':
             actions.double_click()
         elif action == 'context_click':
             actions.context_click()
         else:
             pass
         actions.perform()
     actions = ActionChains(self.driver)
     actions.key_down(key_map[key])
     actions.key_up(key_map[key])
     actions.perform()
Example #13
0
 def editTime(self, driver):
     #登录
     login = Login()
     login.test_click_login_btn(driver)
     sleep(5)
     #点击首页DO确定
     driver.find_element(*self.DOElement).click()
     sleep(5)
     #按状态检索
     driver.find_element(*self.DOstatusElement).click()
     driver.find_element(*self.selDOstatusElement).click()
     #点击检索
     driver.find_element(*self.selElement).click()
     sleep(1)
     #选择数据
     driver.find_element(*self.selDateElement).click()
     #点击配送再确定
     driver.find_element(*self.reconDoElement).click()
     sleep(5)
     #修改纳入时间
     time = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
     time = time[8:12]
     action = ActionChains(driver)
     ele = driver.find_element(*self.inclusionTimeElement)
     action.double_click(ele).perform()
     driver.find_element(*self.inclusionTimeElement).send_keys(time)
     #点击保存
     driver.find_element(*self.saveElement).click()
     sleep(1)
     #确定
     driver.find_element(*self.determineElement).click()
Example #14
0
 def double_click(self):
     driver.get('http://testautomationpractice.blogspot.com/')
     driver.maximize_window()
     element = driver.find_element_by_xpath(
         '//*[@id="HTML10"]/div[1]/button')
     double_click = ActionChains(driver)
     double_click.double_click(element).perform()
Example #15
0
def test_on_label_changed(graph_cases):
    """
    :type graph_cases: qmxgraph.tests.conftest.GraphCaseFactory
    """
    graph = graph_cases('1v')
    vertex_id = graph.get_id(graph.get_vertex())

    # Sanity check: custom tags are internally stored in same node element as
    # label. This is to make sure tags aren't lost when label is changed by
    # mistakenly overwriting whole node element instead of just label.
    graph.eval_js_function('api.setTag', vertex_id, 'test', 'test')

    label = graph.get_label(graph.get_vertex())
    label_element = graph.get_label_element(graph.get_vertex())

    actions = ActionChains(graph.selenium)
    actions.double_click(label_element)
    actions.send_keys('foo')
    actions.click(graph.get_container())  # to lose focus and confirm
    actions.perform()

    assert graph.get_label(graph.get_vertex()) == 'foo'
    label_changes = graph.get_label_changes()
    assert label_changes == \
        [{
            'cellId': vertex_id,
            'newLabel': 'foo',
            'oldLabel': label,
        }]
    assert graph.eval_js_function('api.getTag', vertex_id, 'test') == 'test'
Example #16
0
 def test_something(self):
     self.driver.get("http://nicolasalvarez.com")
     time.sleep(4)
     dobleclick= self.driver.find_element_by_xpath("//*[@id='recent-posts-2']/h3/span")
     actions = ActionChains(self.driver)
     actions.double_click(dobleclick).perform()
     time.sleep(4)
	def test_subir_archivo(self):
		self.driver.get("https://nicolasalvarez.com/")
		time.sleep(4)
		dobleclick = self.driver.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/div[2]/aside[1]/h3/span")
		actions = ActionChains(self.driver)
		actions.double_click(dobleclick).perform()
		time.sleep(3)
Example #18
0
    def otherCharge(self,driver):
        eu = ElementUtil()
        #登录
        login = Login()
        login.test_click_login_btn(driver)
        #点击做成
        eu.click(driver,15,'doc费用增加',*self.outWardElement)
        #输入B/L NO 
        eu.send_keys(driver, 15, self.BLNO,'doc费用增加',*self.BLNoEelement)
        #点击检索
        eu.click(driver,15,'doc费用增加',*self.selElement)

        #选择要修改的数据
        el = driver.find_element(*self.selDateElement)
        el.send_keys(Keys.SPACE)
        #点击编辑
        eu.click(driver,15,'doc费用增加',*self.editElement)
        #双击金额文本框
        action = ActionChains(driver)
        on_element = driver.find_element(*self.otherElement)
        action.double_click(on_element).perform()
        #输入DOCFEE金额为1000
        driver.find_element(*self.otherElement).send_keys(1000)
        #拖动滚动条到最顶部  10000为底部
        scro="document.documentElement.scrollTop=0"
        driver.execute_script(scro)
        #点击海上航空计算
        eu.click(driver,15,'doc费用增加',*self.costCalElement)
        sleep(8)
        # 点击确定
        eu.click(driver, 15, 'doc费用增加',*self.doElement)
        # 点击返回
        eu.click(driver, 15, 'doc费用增加',*self.backElement)
Example #19
0
 def double_click(self, element):
     # webdriver.ActionChains(DriverUtil.get_driver()).click(element).perform()
     try:
         print("{}鼠标点击按钮成功".format(element))
         ActionChains.double_click(element).perform()
     except Exception as e:
         print(e, "{}鼠标点击按钮失败".format(element))
Example #20
0
 def test_1_view_alignment(self):
     actions = ActionChains(self.driver)
     rows = self.waitForAll(
         '.public_fixedDataTable_bodyRow .public_fixedDataTableCell_cellContent'
     )
     actions.double_click(rows[0]).perform()
     self.waitFor('.igv-modal', 3)
Example #21
0
 def outWard(self, driver):
     login = Login()
     login.test_click_login_btn(driver)
     #点击 フレイトI/V作成
     driver.find_element(*self.outWardElement).click()
     sleep(2)
     #清空提单号
     driver.find_element(*self.BLNoEelement).click()
     driver.find_element(*self.BLNoEelement).clear()
     #输入提单号
     driver.find_element(*self.BLNoEelement).send_keys('Practise 38')
     #点击检索
     driver.find_element(*self.searchElement).click()
     sleep(2)
     #选择需要勾选的数据
     driver.find_element(*self.selDataElement).send_keys(Keys.SPACE)
     #点击海上,航空运凭计算
     driver.find_element(*self.transportationElement).click()
     sleep(5)  #加载时间较长  时间短容易造成找不到元素
     #双击金额文本框
     action = ActionChains(driver)
     on_element = driver.find_element(*self.FEEElement)
     action.double_click(on_element).perform()
     sleep(2)
     #输入FEE金额
     driver.find_element(*self.FEEElement).send_keys(1000)
     #拖动滚动条到最顶部  10000为底部
     scro = "document.documentElement.scrollTop=0"
     driver.execute_script(scro)
     sleep(1)
     #点击保存
     driver.find_element(*self.preserveElement).click()
     sleep(2)
Example #22
0
 def move_by_offset_and_click(self, xoffset=0, yoffset=0, action='click'):
     """
     移动到指定坐标
     :param xoffset:
     :param yoffset:
     :return:
     """
     action_select = ['click', 'double_click', 'context_click']
     if action not in action_select:
         LOG_DEBUG('action: {}参数错误, 可选参数为: {}'.format(action, action_select))
     try:
         LOG_DEBUG('移动到坐标 x:{}, y:{}, 点击坐标'.format(xoffset, yoffset))
         actions = ActionChains(self.driver)
         actions.move_by_offset(xoffset, yoffset)
         if action == 'click':
             actions.click()
         elif action == 'double_click':
             actions.double_click()
         elif action == 'context_click':
             actions.context_click()
         else:
             pass
         actions.perform()
     except Exception as e:
         LOG_DEBUG('移动坐标失败: {}'.format(e))
Example #23
0
 def double_click(self, element):
     try:
         test_element = WebDriverWait(self.driver,
                                      10).until(EC.visibility_of(element))
         actions = ActionChains(self.driver)
         actions.double_click(test_element).perform()
     except:
         raise Exception("Double click didn't work properly")
 def select_my_organization(self):
     self.open_ems_iframe()
     action_chain = ActionChains(self.app.driver)
     action_chain.double_click(self.app.driver.find_element_by_xpath("(//a[contains(@class,'emsHeader_areaLink')]) [3]")).perform()       #####    (//div[contains(@class,'emsList__row')]) [4]
     action_chain = ActionChains(self.app.driver)
     action_chain.double_click(
         self.app.driver.find_element_by_xpath("(//div[contains(@class,'emsList__row')]) [4]")).perform()
     self.app.driver.switch_to.default_content()
Example #25
0
 def doubleclick(self, *loc):
     element = self.find_element(*loc)
     try:
         action_chains = ActionChains(self.driver)
         action_chains.double_click(element).perform()
         logger.info('双击正确')
     except:
         logger.error('双击失败')
Example #26
0
 def test_a(self):
     self.driver.get('https://www.baidu.com/')
     action = ActionChains(self.driver)
     a = self.driver.find_element(By.XPATH, '//*[@id="s-top-left"]//a[2]')
     action.click(a)
     action.double_click(a)
     action.perform()
     sleep(4)
 def actionchain_doubleclick(self, ele):
     '''
     使用 ActionChain对元素进行双击,传入参数 ele为元素
     :param ele: 元素
     '''
     action = ActionChains(self.driver)
     action.double_click(ele)
     action.perform()
Example #28
0
 def doubleClick(self, locator, locatorType='xpath'):
     try:
         Action = ActionChains(self.driver)
         Action.double_click(locator)
         return True
     finally:
         self.logs.error(locator + " is Not present on Page")
         return False
Example #29
0
 def test_dobleclick(self):
     URL = 'F:\gitstorehouse\selenium3.0\webdriverAPI接口\测试页面\双击.html'
     self.driver.get(URL)
     inputbox = self.driver.find_element_by_id('input1')
     from selenium.webdriver import ActionChains
     action_chains = ActionChains(self.driver)
     action_chains.double_click(inputbox).perform()
     sleep(5)
def boxi_overtime_extract():
    boxi_iframe_switch()
    actionChains = ActionChains(browser)
    actionChains.double_click(
        browser.find_element_by_id('ListingURE_listColumn_4_0_1')).perform()

    try:
        WebDriverWait(browser, 10).until(
            ec.frame_to_be_available_and_switch_to_it('webiViewFrame'))

    except TimeoutException:
        print("Loading took too much time!")
    browser.find_element_by_xpath('//*[@id="IconImg_Txt_refresh"]').click()
    try:
        WebDriverWait(browser, 10).until(
            ec.presence_of_element_located((By.XPATH, '// *[ @ id = "PV1"]')))
    except TimeoutException:
        print("Loading took too much time!")
    dateinput = browser.find_element_by_id('LPV1_textField')
    firstelem = browser.find_element_by_xpath(
        '//*[@id="mlst_bodyPV1List"]/div/table/tbody/tr[1]/td/div')
    secondelem = browser.find_element_by_xpath(
        '//*[@id="mlst_bodyPV1List"]/div/table/tbody/tr[5]/td/div')
    actionChains = ActionChains(browser)
    actionChains.key_down(
        Keys.SHIFT).click(firstelem).click(secondelem).key_up(
            Keys.SHIFT).perform()
    browser.find_element_by_xpath('//*[@id="theBttnIconPV1DelButton"]').click()

    for i in finweeks:
        dateinput.clear()
        dateinput.send_keys(i)
        browser.find_element_by_id("theBttnIconPV1AddButton").click()
    dateinput.clear()
    dateinput.send_keys(finmonth)
    browser.find_element_by_id("theBttnIconPV1AddButton").click()
    browser.find_element_by_id("theBttnCenterImgpromptsOKButton").click()
    try:
        WebDriverWait(browser, 250).until(
            ec.presence_of_element_located(
                (By.XPATH, '//*[@id="IconImg_iconMenu_arrow_docMenu"]')))

    except TimeoutException:
        print("Loading took too much time!")
    browser.find_element_by_xpath(
        '//*[@id="IconImg_iconMenu_arrow_docMenu"]').click()
    hov = browser.find_element_by_id(
        'iconMenu_menu_docMenu_span_text_saveReportComputerAs')
    ActionChains(browser).move_to_element(hov).perform()
    time.sleep(1)
    browser.find_element_by_id(
        'saveReportComputerAs_span_text_saveReportXLS').click()
    print(path + 'WSTATS_OVERTIME_EXTRACT' + '.xls')
    while not os.path.exists(path + 'WSTATS_OVERTIME_EXTRACT.xls'):
        time.sleep(1)
    browser.get('https://bo-wf.scot.nhs.uk/InfoViewApp/listing/main.do')
    browser.switch_to.alert.accept()
    print("Boxi Overtime Extract - Complete")
Example #31
0
 def select(self, index):
     """ Sets a ``select`` element to `index` . """
     chain = ActionChains(self._browser)
     chain.double_click(self._root).perform()
     element = self._root.find_elements(By.XPATH, 'select')[0]
     WebDriverWait(self._browser, 5).until(
         lambda browser: element.is_displayed())
     WebDriverWait(self._browser, 5).until(
         lambda browser: element.is_enabled())
     option = element.find_elements(By.XPATH, 'option')[index]
     option.click()
Example #32
0
 def value(self, value):
     chain = ActionChains(self._browser)
     chain.double_click(self._root).perform()
     element = self._root.find_elements(By.XPATH, 'input')[0]
     WebDriverWait(self._browser, 5).until(
         lambda browser: element.is_displayed())
     WebDriverWait(self._browser, 5).until(
         lambda browser: element.is_enabled())
     if element.get_attribute('value'):
         element.clear()
     time.sleep(0.1)  # Just some pacing.
     element.send_keys(value + Keys.RETURN)
 def test_task_C7(self):
     # test_profile_update
     # Task C7.	As a logged in user I want to be able to change my staff number and managers email
     self._login_user()
     self.browser.find_element_by_id('id_account').click()
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Profile')))
     self.browser.find_element_by_id('id_staff_number').send_keys('54321')
     action_chains = ActionChains(self.browser)
     action_chains.double_click(self.browser.find_element_by_id('id_manager_email')).perform()
     self.browser.find_element_by_id('id_manager_email').send_keys(MANAGER2)
     self.browser.find_element_by_id('update_profile_button').click()
     self.assertTrue(WebDriverWait(self.browser, 10).until(ec.title_is('Home')))
 def editor_page(self, double_click=True, base_type='Component'):
     """ Return :class:`ComponentPage` for this component. """
     chain = ActionChains(self.browser)
     if double_click:
         chain.double_click(self.root).perform()
     else:
         self._context_click('edit_button')
     editor_id = 'CE-%s' % self.pathname.replace('.', '-')
     if base_type == 'Assembly':
         return AssemblyPage(self.browser, self.port, (By.ID, editor_id))
     elif base_type == 'Driver':
         return DriverPage(self.browser, self.port, (By.ID, editor_id))
     else:
         return ComponentPage(self.browser, self.port, (By.ID, editor_id))
Example #35
0
    def create(self, tr):
        self.tds = tr.find_elements_by_tag_name('td')

        actions = ActionChains(self.driver)
        actions.move_to_element(self.tds[1])
        actions.double_click()
        actions.send_keys(lorem_ipsum.words(1, False))
        actions.perform()

        actions.move_to_element(self.tds[2])
        actions.double_click()
        actions.perform()

        self.driver.select('select.htSelectEditor', unicode(self.experiment.pk))
        self.driver.click('body')
Example #36
0
 def edit_file(self, filename, dclick=True):
     """ Edit `filename` via double-click or context menu. """
     xpath = "//a[(@path='/%s')]" % filename
     element = WebDriverWait(self.browser, TMO).until(lambda browser: browser.find_element_by_xpath(xpath))
     chain = ActionChains(self.browser)
     for i in range(10):
         try:
             if dclick:
                 chain.double_click(element).perform()
             else:
                 chain.context_click(element).perform()
                 self("file_edit").click()
         except StaleElementReferenceException:
             logging.warning("edit_file: StaleElementReferenceException")
             element = WebDriverWait(self.browser, 1).until(lambda browser: browser.find_element_by_xpath(xpath))
             chain = ActionChains(self.browser)
         else:
             break
    def connect(self):
        print 'Spotify Social Network Project'
        print '=============================='

        # Open a broswer and navigate to the Spotify player
        print 'Creating webdriver ...'
        options = webdriver.ChromeOptions()
        options.add_experimental_option("excludeSwitches", 
		["ignore-certificate-errors"]) # Suppress a command-line flag
	self.display.start()
        self.driver = webdriver.Chrome(chrome_options=options, 
		service_args=["--verbose", "--log-path=webdriver.log"])
        self.driver.implicitly_wait(2)

        print 'Navigating to Spotify ...'
        self.driver.get('http://play.spotify.com/')

        # Click the "Already have an account" link
	action_chains = ActionChains(self.driver)
        login = WebDriverWait(self.driver, 10).until(
		EC.element_to_be_clickable((By.ID, 'has-account')))
	action_chains.double_click(login).perform()

        # Type in credentials at the command line to log in Spotiy with Facebook
        fb_login = WebDriverWait(self.driver, 10).until(
		EC.element_to_be_clickable((By.ID, 'fb-login-btn')))
        fb_login.click()
        self.driver.switch_to_window(self.driver.window_handles[1])
        print 'Logging in via Facebook ...'
        email_blank = self.driver.find_element_by_id('email')
        pass_blank  = self.driver.find_element_by_id('pass')
        input_email = raw_input('Email or Phone: ')
        input_pass  = getpass.getpass('      Password: '******'Waiting for Spotify to load ...'
        self.driver.switch_to_window(self.driver.window_handles[0])
        WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//li[@class='item-profile etched-top has-extra-bottom-row show show show show']")))
        print 'Connection complete ...'
        print '=============================='
Example #38
0
 def view_geometry(self, filename, dclick=True):
     """ View geometry `filename` via double-click or context menu. """
     self('files_tab').click()
     element = self.find_file(filename)
     chain = ActionChains(self.browser)
     if dclick:  # This has had issues...
         for i in range(10):
             try:
                 chain.double_click(element).perform()
             except StaleElementReferenceException:
                 logging.warning('edit_file: StaleElementReferenceException')
                 element = self.find_file(filename, 1)
                 chain = ActionChains(self.browser)
             else:
                 break
     else:
         chain.context_click(element).perform()
         self('file_geometry').click()
     self.browser.switch_to_window(self.browser.window_handles[-1])
     return GeometryPage.verify(self.browser, self.port)
Example #39
0
 def edit_file(self, filename, dclick=True):
     """ Edit `filename` via double-click or context menu. """
     self("files_tab").click()
     element = self.find_file(filename)
     chain = ActionChains(self.browser)
     if dclick:  # This has had issues...
         for i in range(10):
             try:
                 chain.double_click(element).perform()
             except StaleElementReferenceException:
                 logging.warning("edit_file: StaleElementReferenceException")
                 element = self.find_file(filename, 1)
                 chain = ActionChains(self.browser)
             else:
                 break
     else:
         chain.context_click(element).perform()
         self("file_edit").click()
     self.browser.switch_to_window("Code Editor")
     return EditorPage.verify(self.browser, self.port)
Example #40
0
 def editor_page(self, double_click=True, base_type='Component',
                 version=ComponentPage.Version.OLD):
     """ Return :class:`ComponentPage` for this component. """
     chain = ActionChains(self.browser)
     if double_click:
         chain.double_click(self.root).perform()
     else:
         self._context_click('edit_button')
     editor_id = 'ObjectFrame_%s' % self.pathname.replace('.', '-')
     chain.release(None).perform()
     if base_type == 'Assembly':
         return AssemblyPage(self.browser, self.port, (By.ID, editor_id))
     elif base_type == 'Driver':
         return DriverPage(self.browser, self.port, (By.ID, editor_id))
     elif base_type == 'ImplicitComponent':
         return ImplicitComponentPage(self.browser, self.port, (By.ID, editor_id),
                              version=version)
     else:
         return ComponentPage(self.browser, self.port, (By.ID, editor_id),
                              version=version)
Example #41
0
File: map.py Project: 2gis/mapsapi
 def center_dbclick(self):
     center = self.driver.execute_script(GetScripts.getContainerCenter)
     actions = ActionChains(self.driver)
     actions.move_to_element_with_offset(self.element, int(center['x']), int(center['y']))
     actions.double_click().perform()
Example #42
0
    def test_storymap(self):
        factories.UserFactory.create(
            email="*****@*****.**",
            password="******",
            is_staff=True,
        )
        self._login("*****@*****.**", "123")
        time.sleep(0.2)
        storymap = factories.StoryMapFactory.create()
        self.browser.get(self.live_reverse("storymap_detail",
                                           args=(storymap.pk,)))
        time.sleep(0.2)
        # Create 2 themes
        for seq in range(2):
            self.sel_query("a.create_theme").click()
            time.sleep(0.2)
            theme_input = self.sel_query("#theme-create-panel textarea")
            theme_input.send_keys("Theme {0}".format(seq))
            self.sel_query("#create-theme-btn").click()
            time.sleep(0.5)
        # Create 2 phase
        for seq in range(2):
            self.sel_query("a.create_phase").click()
            time.sleep(0.2)
            theme_input = self.sel_query("#phase-create-panel textarea")
            theme_input.send_keys("Phase {0}".format(seq))
            self.sel_query("#create-phase-btn").click()
            time.sleep(0.5)
        # let's move to the theme and phase to display the "new story" button
        actionChains = ActionChains(self.browser)
        actionChains.move_to_element(self.sel_query(".stories-zone"))
        actionChains.perform()
        time.sleep(0.2)
        self.sel_query(".create_story").click()
        time.sleep(0.2)
        actionChains = ActionChains(self.browser)
        actionChains.send_keys("My first story\n")
        actionChains.perform()
        time.sleep(0.2)

        actionChains = ActionChains(self.browser)
        actionChains.move_to_element(self.sel_query(".stories-zone"))
        actionChains.perform()
        time.sleep(0.2)
        self.sel_query(".create_story").click()
        actionChains = ActionChains(self.browser)
        actionChains.send_keys("My second story\n")
        actionChains.perform()
        time.sleep(0.2)

        story = Story.objects.get(title="My first story")
        phase_1 = Phase.objects.get(name="Phase 1")
        theme_0 = Theme.objects.get(name="Theme 0")

        # move story to another phase
        actionChains = ActionChains(self.browser)
        actionChains.drag_and_drop(
            self.sel_query('.story-cell[story-id="{0}"]'.format(story.pk)),
            self.sel_query('.stories-zone[phase-id="{0}"]'.format(phase_1.pk)),
        )
        actionChains.perform()
        time.sleep(0.2)

        storymap = StoryMap.objects.get(pk=storymap.pk)
        self.assertEqual(storymap.themes.all()[0].name, "Theme 0")
        self.assertEqual(storymap.themes.all()[1].name, "Theme 1")
        self.assertEqual(storymap.phases.all()[0].name, "Phase 0")
        self.assertEqual(storymap.phases.all()[1].name, "Phase 1")
        story = Story.objects.get(title="My first story")
        self.assertEqual(story.phase_id, phase_1.pk)
        self.assertEqual(story.theme_id, theme_0.pk)

        # Edit story
        actionChains = ActionChains(self.browser)
        actionChains.double_click(self.sel_query(
            '.story-cell[story-id="{0}"] .story'.format(
                story.pk
            )
        ))
        actionChains.perform()
        actionChains = ActionChains(self.browser)
        actionChains.send_keys("Edited \n")
        actionChains.perform()
        time.sleep(1)

        self.assertTrue(Story.objects.get(title="Edited My first story"))

        # delete theme 1
        theme = Theme.objects.get(name="Theme 1")
        actionChains = ActionChains(self.browser)
        actionChains.move_to_element(self.sel_query(
            '.theme-cell[theme-id="{0}"]'.format(theme.pk)))
        actionChains.click(self.sel_query(
            '.theme-cell[theme-id="{0}"] .delete_theme'.format(theme.pk)))
        actionChains.perform()
        time.sleep(0.2)
        self.sel_query("#confirm-delete-btn").click()
        time.sleep(0.5)

        # delete phase 0
        phase = Phase.objects.get(name="Phase 0")
        actionChains = ActionChains(self.browser)
        actionChains.move_to_element(self.sel_query(
            '.phase-cell[phase-id="{0}"]'.format(phase.pk)))
        actionChains.click(self.sel_query(
            '.phase-cell[phase-id="{0}"] .delete_phase'.format(phase.pk)))
        actionChains.perform()
        time.sleep(0.2)
        self.sel_query("#confirm-delete-btn").click()
        time.sleep(0.5)

        # delete last story
        actionChains = ActionChains(self.browser)
        actionChains.move_to_element(self.sel_query(
            '.story-cell[story-id="{0}"]'.format(story.pk)))
        actionChains.click(self.sel_query(
            '.story-cell[story-id="{0}"] .delete_story'.format(story.pk)))
        actionChains.perform()
        time.sleep(0.2)
        self.sel_query("#confirm-delete-btn").click()
        time.sleep(0.5)

        # Only one story theme and phase should exists
        self.assertFalse(Story.objects.exists())
        self.assertTrue(Theme.objects.get())
        self.assertTrue(Theme.objects.get())
Example #43
0
    def test_drw_3_1_5(self):
        self.screenshot('screen-drw-09a')

        link = self.portal.find_element_by_partial_link_text("Taxonomic Refinement")
        self.pause(1)
        self.portal.click(link)

        self.screenshot('screen-drw-10a')

        run = self.runExistingWorkflow('Data Refinement Workflow v15')
        if self.screenshotBase:
            os.rename(self.screenshotName('WorkflowDetails'), self.screenshotName('screen-drw-10b'))
            os.rename(self.screenshotName('WorkflowInputs'), self.screenshotName('screen-drw-11a'))

        # Store the run URL here, to help with browser restart. If we do this
        # later, we tend to get the interaction page URL instead
        runUrl = self.portal.current_url

        # Choose Input file
        with run.waitForInteraction(300) as interaction:
            continueButton = self.portal.wait(60).until(
                expected_conditions.element_to_be_clickable((By.XPATH, '//button/div[text()="Submit"]')))
            title = self.portal.find_element_by_xpath('/html/body/table/tbody/tr[1]/td/div').text
            self.assertEqual(title, 'Choose Input file')
            fileInput = self.portal.find_element_by_xpath('/html/body/table/tbody/tr[2]/td/form/input')
            self.pause(1)
            fileInput.send_keys(self.inputFile)
            self.screenshot('screen-drw-11b', interaction.location, interaction.size)
            self.pause(1)
            self.portal.click(continueButton)

        class ExitInteraction(Exception):
            pass
        try:
            # Choose Sub-workflow
            with run.waitForInteraction(300) as interaction:
                continueButton = self.portal.wait(60).until(
                    expected_conditions.element_to_be_clickable((By.XPATH, '//button/div[text()="OK"]')))
                title = self.portal.find_element_by_xpath('/html/body/table/tbody/tr[1]/td/div').text
                self.assertEqual(title, 'Choose Sub-Workflow')
                self.screenshot('screen-drw-12a', interaction.location, interaction.size)
                self.pause(1)
                # For normal exit of the with block, the code will wait until
                # the interaction disappears. To exit without that, we raise
                # an exception.
                raise ExitInteraction()
        except ExitInteraction:
            pass

        # Demonstration of quitting browser, and restarting
        self.restartBrowser()
        self.pause(1)
        self.screenshot('screen-drw-12b')

        self.portal.selectRunsTab()
        self.pause(1)
        self.screenshot('screen-drw-13a')

        # Return to run - we don't actually select the run from the Runs tab, as
        # we would have to work out which run was ours - we use our saved URL
        self.portal.get(runUrl)

        # Need to update run to use new portal
        run = WorkflowRun(self, self.portal)
        time.sleep(2)

        # Choose Sub-workflow
        with run.waitForInteraction(300) as interaction:
            continueButton = self.portal.wait(60).until(
                expected_conditions.element_to_be_clickable((By.XPATH, '//button/div[text()="OK"]')))
            title = self.portal.find_element_by_xpath('/html/body/table/tbody/tr[1]/td/div').text
            self.assertEqual(title, 'Choose Sub-Workflow')
            input = self.portal.find_element_by_xpath('//label[text()="Data Selection (BioSTIF)"]/../input')
            self.pause(1)
            input.click()
            self.screenshot('screen-drw-13b', interaction.location, interaction.size)
            self.pause(1)
            self.portal.click(continueButton)

        # BioSTIF
        with run.waitForInteraction(300) as interaction:
            # There are a series of alerts that may show up during BioSTIF
            # initialisation. We can usually plough on after accepting, but
            # sometimes it's a real failure and we need to abort
            try:
                self.portal.wait(15).until(
                    expected_conditions.alert_is_present()
                    )
                self.pause(5)
                alert = self.portal.switch_to_alert()
                text = alert.text
                if text == '[msg_error_application_start_failed]':
                    alert.accept()
                    self.portal.switch_to_default_content()
                    interaction.switchBack()
                    self.portal.wait(15).until(
                        expected_conditions.alert_is_present()
                        )
                    self.pause(5)
                    alert = self.portal.switch_to_alert()
                    text = alert.text
                self.assertEqual(text, 'BioSTIF cannot be started OpenLayers is not defined')
                alert.accept()
                try:
                    self.portal.switch_to_default_content()
                except UnexpectedAlertPresentException:
                    # Sometimes, in Chrome, a third dialog appears immediately
                    # after the above one - and we cannot continue
                    alert = self.portal.switch_to_alert()
                    self.assertEqual(alert.text, 'BioSTiF could not start:  an error occurred: Error initializing BioSTIF: OpenLayers is not defined')
                    self.fail("Dreaded third alert, which I can't handle - try running the test again")
                interaction.switchBack()
            except TimeoutException:
                # Normal execution with no alerts (or only the first) should
                # end up here
                pass

            # Select draw polygon
            polygonButton = self.portal.wait(60).until(
                expected_conditions.presence_of_element_located(
                    (By.CSS_SELECTOR, "div.mapControl.polygonDeactivated")
                    )
                )
            polygonButton.click()

            # Get size of map view
            mapViewPortElement = self.portal.wait(10).until(
                expected_conditions.presence_of_element_located(
                    (By.ID, "OpenLayers.Map_12_OpenLayers_ViewPort")
                    )
                )
            mapHeight = mapViewPortElement.size['height']
            mapWidth = mapViewPortElement.size['width']

            with open('file0.html', 'wt') as f:
                f.write(self.portal.page_source)

            # Define the points where we are going to click to make the polygon
            points = [(0.45, 0.5), (0.42, 0.7), (0.53, 0.9), (0.55, 0.5)]

            # Draw the polygon
            (prevX, prevY) = points.pop(0)
            chain = ActionChains(self.portal.browser).move_to_element_with_offset(
                mapViewPortElement, int(prevX*mapWidth), int(prevY*mapHeight)
                )
            for (x, y) in points:
                chain = chain.click().move_by_offset(
                    int((x-prevX)*mapWidth), int((y-prevY)*mapHeight)
                    )
                prevX = x
                prevY = y
            chain.double_click().perform()
            time.sleep(5)
            self.screenshot('screen-drw-14a', interaction.location, interaction.size)

            # Filter elements inside polygon
            filterButton = self.portal.wait(30).until(
                expected_conditions.presence_of_element_located(
                    (By.ID, "smallButton filter")
                    )
                )
            self.pause(1)
            filterButton.click()

            # We cheat a little here. Removing the layers is tricky using
            # Selenium because the 'no overlay' option is not visible on many
            # displays. Scrolling a menu created using a div and CSS is hard,
            # so we reverse the order of the screenshots to get what we need
            time.sleep(5)
            self.screenshot('screen-drw-15a', interaction.location, interaction.size)

            dropdown = self.portal.find_element_by_xpath('//div[@id="mapContainerDiv"]//div[@title="Select layer for spatial filtering"]')
            self.pause(1)
            dropdown.click()

            menuItem = dropdown.find_element_by_xpath('..//dt[text()="ETOPO1 Global Relief Model"]')
            self.pause(1)
            menuItem.click()

            # For screenshot, we let the layer load, and then open the menu again
            time.sleep(5)
            dropdown.click()
            time.sleep(1)
            self.screenshot('screen-drw-14b', interaction.location, interaction.size)

            # Click ok to save changes and go back to subworkflow chooser
            bioStifSaveButton = self.portal.wait(10).until(
                expected_conditions.presence_of_element_located(
                    (By.ID, "user_ok")
                    )
                )
            bioStifSaveButton.click()

        # Choose Sub-workflow
        with run.waitForInteraction(300):
            continueButton = self.portal.wait(60).until(
                expected_conditions.element_to_be_clickable((By.XPATH, '//button/div[text()="OK"]')))
            title = self.portal.find_element_by_xpath('/html/body/table/tbody/tr[1]/td/div').text
            self.assertEqual(title, 'Choose Sub-Workflow')
            input = self.portal.find_element_by_xpath('//label[text()="End Workflow"]/../input')
            self.pause(1)
            input.click()
            self.pause(1)
            self.portal.click(continueButton)

        results = run.waitForFinish(120)

        csv_output = results['csv_output'].getValue()
        count = csv_output.count('\n')
        print(count)
Example #44
0
    def test_create_article(self):

        article = self.driver.find_element_by_class_name("icon-pencil").click()
        action = Ac(self.driver)
        action.move_to_element(article)
        action.double_click(article).perform()
Example #45
0
print '\n',"driver.find_element_by_class_name('content')"
print content

content = driver.find_element_by_css_selector('p.content')
print '\n',"driver.find_element_by_css_selector('p.content')"
print content


element = driver.find_element_by_xpath("//form[@id='loginForm']")
all_options = element.find_elements_by_tag_name("input")
for option in all_options:
	print("Value is: %s" % option.get_attribute("name"))
	# option.send_keys(option.get_attribute("name"))
	t = option.get_attribute("type")
	if t == 'Login' or t == 'Clear' :
		print (t)
		option.click()
	if option.get_attribute("name") == 'username':
		option.send_keys('source')


element = driver.find_element_by_class_name('content')
target = driver.find_element_by_name("username1")
print element.text

from selenium.webdriver import ActionChains
action_chains = ActionChains(driver)
action_chains.double_click(element).drag_and_drop(element, target).perform()


# driver.quit()