Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

long press selenium python

#encoding=utf-8
import unittest
import time
from selenium import webdriver
from selenium.webdriver import ActionChains
import win32clipboard as w
import win32con

# Set clipboard content
def setText(aString):
    w.OpenClipboard()
    w.EmptyClipboard()
    w.SetClipboardData(win32con.CF_UNICODETEXT, aString)
    w.CloseClipboard()


class VisitSogouByIE(unittest.TestCase):

    def setUp(self):
        #Start IE browser
        #self.driver = webdriver.Firefox(executable_path = "e:geckodriver")
        self.driver = webdriver.Ie(executable_path = "e:IEDriverServer")
        
    def test_simulationLeftClickMouseOfProcess(self):
        url = "http://127.0.0.1/test_mouse.html"
        #  Visit a custom html page
        self.driver.get(url)
        div = self.driver.find_element_by_id("div1")
        from selenium.webdriver import ActionChains
        import time
        #  Press and hold the left mouse button on the element whose id attribute value is "div1"
        ActionChains(self.driver).click_and_hold(div).perform()
        time.sleep(2)
        #  Release the left mouse button that has been released on the element whose id attribute value is "div1"
        ActionChains(self.driver).release(div).perform()
        time.sleep(2)
        ActionChains(self.driver).click_and_hold(div).perform()
        time.sleep(2)
        ActionChains(self.driver).release(div).perform()

    def tearDown(self):
        #  Exit IE browser
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()
Source by www.programmerall.com #
 
PREVIOUS NEXT
Tagged: #long #press #selenium #python
ADD COMMENT
Topic
Name
1+1 =