250x250
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- r
- 지마켓
- 과학백과사전
- (깃)git bash
- java
- oracle
- 코사인 유사도
- Topics
- Websocket
- 자바
- 토픽추출
- word2vec
- Python
- lda
- mysql
- pytorch
- 이력서
- 방식으로 텍스트
- 크롤링
- 게시판 만들기
- db
- spring MVC(모델2)방식
- 네이버뉴스
- 幼稚园杀手(유치원킬러)
- RESFUL
- tomoto
- Gmarket
- test
- 파이썬
- jsp 파일 설정
Archives
- Today
- Total
무회blog
python: 지정좌표 클릭, 드래그 본문
드래그
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
driver = webdriver.Chrome()
driver.implicitly_wait(10)
driver.maximize_window()
driver.get('http://sahitest.com/demo/dragDropMooTools.htm')
dragger = driver.find_element_by_id('dragger') # 被拖拽元素
# item1 = driver.find_element_by_xpath('//div[text()="Item 1"]') # 目标元素1
item1 = driver.find_element_by_xpath('/html/body/div[2]') # 目标元素1
item3 = driver.find_element_by_xpath('/html/body/div[4]') # 目标3
item4 = driver.find_element_by_xpath('/html/body/div[5]') # 目标4
action = ActionChains(driver)
action.drag_and_drop(dragger, item1).perform() # 1.移动dragger到目标1
sleep(2)
action.click_and_hold(dragger).move_to_element(item3).release().perform() # 3.效果与上两句相同,也能起到移动的效果
sleep(2)
action.drag_and_drop_by_offset(dragger, 400, 150).perform() # 4.移动到指定坐标
action.click_and_hold(dragger).move_by_offset(400, 150).release().perform() # 5.与上一句相同,移动到指定坐标
sleep(2)
# =============================================================================
# dragger = driver.find_element_by_id('dragger') # 被拖拽元素
# item1 = driver.find_element_by_xpath('/html/body/div[2]') # 目标元素1
# action = ActionChains(driver)
# action.drag_and_drop(dragger, item1).perform() # 1.移动dragger到目标1
# sleep(2)
# =============================================================================
driver.quit()
좌표 클릭
# =============================================================================
# tester2
# =============================================================================
import pyautogui as pa
import time
# 目前坐标确定
print(pa.position())
# 指定坐标移动
pa.moveTo(953,348,1)
# 目前坐标移动
# pa.moveRel(953, 348,1)
# =============================================================================
# clicks 点击数量
# interval 点击时间
# =============================================================================
# pa.click(clicks=2, interval=2);
# 双击
pa.doubleClick();
time.sleep(1)
pa.typewrite('hello');
# 回车
pa.typewrite(['enter']);
pa.typewrite(['a','b','c','enter']);
이메일 보내기
# =============================================================================
# login button, login id
# =============================================================================
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time
dr = webdriver.Chrome()
url = 'https://google.com'
dr.get(url)
# 窗口 最大化
dr.maximize_window()
# driver input . action 控制 driver
action = ActionChains(dr)
logini = '#gb > div > div.gb_Te > a'
dr.find_element_by_css_selector(logini).click()
action.send_keys('tncnsff89').perform()
nexti = '#identifierNext > div > button > div.VfPpkd-RLmnJb'
dr.find_element_by_css_selector(nexti).click()
# =============================================================================
# 이메일보내기
# 括号 表示 里面的 可看做一行
# pause(2) : sleep(2)
# key_down(Keys.TAB) : TAB Button anzhu
# action.reset_actions() : action reset
# =============================================================================
action.reset_actions()
send_button = 'selector'
(
action.send_keys('testsss').pause(2).key_down(Keys.TAB).key_down(Keys.TAB)
.send_keys('제목입니다.').pause(2).key_down(Keys.TAB)
.send_keys('내용입니다.').pause(2).key_down(Keys.ENTER)
.move_to_element(send_button).click()
.perform()
)
'Python' 카테고리의 다른 글
python: 정규식 예제,test (0) | 2021.03.15 |
---|---|
python:리스트를, 단위별,(7개씩) 자르고, 리스트에 담게 ,split 용 (0) | 2021.03.02 |
python:Python利用pandas处理Excel数据 (0) | 2021.02.08 |
使用,Pandas,进行大型,Excel,文件处理 (0) | 2021.02.08 |
python:정규표현식 ,정규표, 메타문자 (0) | 2020.09.10 |
Comments