XXQQ123

1、文件上传2中场景    直接send_keys(file_path)      第二种通过三方调用(调用浏览器之外的系统需要进行等待time.sleep())

from pywinauto import Desktop
app = Desktop()
dialog = app[\'打开\']    #根据名字找到弹出窗口
dialog["Edit"].type_keys(file_path)     # 在输入框中输入值
dialog["Button"].click()
#linux系统下
import pyautogui
import pyperclip

pyperclip.copy(file_path)

time.sleep(2)
pyautogui.hotkey(\'ctrl\', \'v\')
pyautogui.press(\'enter\', presses=2)

time.sleep(2)

2、滚动条

driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://readhub.cn/topics")

# 滑动到页面最底部

for i in range(5):
    js_code = \'window.scrollTo(0, document.body.scrollHeight);\'
    driver.execute_script(js_code)

time.sleep(3)

  

"""滚动条滚动到当前元素"""
# 先定位 常见问题
el = driver.find_element_by_link_text("常见问题")
# 把 常见问题的元素 滑动的可见范围内
el.location_once_scrolled_into_view

 3、执行js代码

e = driver.find_element_by_id("train_date")

# 发送 js code 给浏览器
js_code = """e = document.getElementById("train_date");"""
driver.execute_script(js_code)

time.sleep(0.2)
js_code = """e.readOnly = false;"""
driver.execute_script(js_code)

time.sleep(0.2)
js_code = """e.value = "2020-07-20";"""
driver.execute_script(js_code)

  

分类:

技术点:

相关文章:

  • 2022-01-10
  • 2021-09-21
  • 2021-10-30
  • 2021-12-30
  • 2021-12-15
  • 2021-09-21
  • 2018-11-25
  • 2021-12-16
猜你喜欢
  • 2021-12-27
  • 2021-09-27
  • 2021-07-30
  • 2021-08-16
  • 2021-12-24
  • 2021-10-19
相关资源
相似解决方案