Ejemplo n.º 1
0
 def test_drag_and_drop(self):
     self.driver.get("http://sahitest.com/demo/dragDropMooTools.htm")
     ele_drag = self.driver.find_element_by_id("dragger")
     ele_drop = self.driver.find_element_by_xpath("/html/body/div[2]")
     action = ActionChains(self.driver)
     action.drag_and_drop(ele_drag, ele_drop)
     action.perform()
     sleep(3)
Ejemplo n.º 2
0
 def test_movetoelement(self):
     self.driver.get("http://www.baidu.com/")
     ele = self.driver.find_element_by_css_selector(
         '[id="s-usersetting-top"]')
     action = ActionChains(self.driver)
     action.move_to_element(ele)
     action.perform()
     sleep(3)
Ejemplo n.º 3
0
 def test_move(self):
     # 光标移动到某个位置上
     self.driver.get("http://www.baidu.com")
     element_move = self.driver.find_element_by_xpath(
         "//*[@id='s-usersetting-top']")
     action = ActionChains(self.driver)
     action.move_to_element(element_move)
     action.perform()
     sleep(3)
Ejemplo n.º 4
0
    def test_touchAction(self):
        self.driver.get("http://www.baidu.com")
        ele = self.driver.find_element_by_xpath("//*[@id='kw']")
        el = self.driver.find_element_by_xpath("//*[@id='su']")
        ele.click()
        ele.send_keys("selenium测试")
        action = TouchActions(self.driver)
        action.tap(el)
        action.perform()
        action.scroll_from_element(ele, 0, 1000).perform()

        sleep(3)
Ejemplo n.º 5
0
 def test_keys(self):
     self.driver.get("http://sahitest.com/demo/label.htm")
     ele = self.driver.find_element_by_xpath("/html/body/label[1]/input")
     ele.click()
     action = ActionChains(self.driver)
     # pouse 暂停
     action.send_keys("username").pause(1)
     action.send_keys(Keys.SPACE).pause(1)
     action.send_keys("tom").pause(1)
     action.send_keys(Keys.BACK_SPACE).pause(1)
     action.perform()
     sleep(3)
Ejemplo n.º 6
0
 def test_click(self):
     self.driver.get("http://sahitest.com/demo/clicks.htm")
     element_click = self.driver.find_element_by_xpath(
         "//input[@value = 'click me']")
     element_duble_click = self.driver.find_element_by_xpath(
         "//input[@value = 'dbl click me']")
     element_dright_click = self.driver.find_element_by_xpath(
         "//input[@value = 'right click me']")
     action = ActionChains(self.driver)
     action.click(element_click)
     action.double_click(element_duble_click)
     action.context_click(element_dright_click)
     action.perform()
Ejemplo n.º 7
0
 def perform_initiative_action(self, actionname, playername, victimname=None):
     if self.is_running():
         player = self.get_player(playername)
         if player is None or player.is_dead():
             return '%s is not playing the game' % playername
         elif not playername == self._turnowner:
             return 'It is not %s\'s turn to take initiative actions' % playername
         elif self._lastaction is not None and not self._lastaction.is_resolved:
             return 'Last action has yet to be resolved'
         elif not self.actions.has_key(actionname):
             return '%s is not a valid initiative action' % actionname
         else:
             actiontype = self.actions[actionname]
             action = actiontype(player)
             action.deck = self._deck
             if victimname is None:
                 victim = None
             else:
                 victim = self.get_player(victimname)
                 if victim is None or victim.is_dead():
                     return '%s chose invalid victim %s for action %s' % (playername, victimname, actionname)
             if action.perform(victim):
                 self._lastaction = action 
                 result = self.auto_advance_and_resolve()
                 return result
             else:
                 return '%s could not perform %s for some reason; investigate please' % (playername, actionname)
     else:
         return 'Game is not running'
Ejemplo n.º 8
0
    def test_case_click(self):
        self.driver.get("http://sahitest.com/demo/clicks.htm")
        #双击
        dbl_click_element = self.driver.find_element(
            By.XPATH, '//input[@value="dbl click me"]')

        #单机
        click_element = self.driver.find_element(By.XPATH,
                                                 '//input[@value="click me"]')

        #右击
        right_click_element = self.driver.find_element(
            By.XPATH, '//input[@value="right click me"]')
        action = ActionChains(self.driver)
        #鼠标单击
        action.click(click_element)
        #鼠标双击
        action.double_click(dbl_click_element)
        #鼠标右击
        action.context_click(right_click_element)
        sleep(3)
        action.perform()
        sleep(3)