zoukankan      html  css  js  c++  java
  • selenium 通过剪切板粘贴(Command+v)方式,向输入框输入内容

    code

    import os
    import sys
    import time
    import pyperclip
    from selenium import webdriver 
    from selenium.webdriver.common.keys import Keys
    
    
    mobileEmulation = {'deviceName' :'Galaxy S5'}
    
    option=webdriver.ChromeOptions()
    
    option.add_experimental_option('mobileEmulation',mobileEmulation)
    
    charome = webdriver.Chrome(options=option)
    charome.get("https://xxx.com/login")
    
    charome.implicitly_wait(3.5)
    charome.find_element_by_xpath(".//input[@placeholder='请输入手机号']").click()
    
    pyperclip.copy("135xxxxxxxx") #在剪切板中插入需要粘贴的文本内容
    time.sleep(2)
    charome.find_element_by_xpath(".//input[@placeholder='请输入手机号']").send_keys(Keys.COMMAND,'v')
    
    charome.implicitly_wait(3.5)
    charome.find_element_by_xpath(".//input[@placeholder='请输入验证码']").click()
    charome.find_element_by_xpath(".//input[@placeholder='请输入验证码']").send_keys("8888")

  • 相关阅读:
    ntopng网络流量实时监控
    LVS初始使用步骤
    Pycharm快捷方式
    Python之路,Day9, 进程、线程、协程篇
    Python之路,Day7
    Python 之路 Day5
    Python之路,Day6
    Python之路,Day3
    Python之路,Day2
    Python之路,Day1
  • 原文地址:https://www.cnblogs.com/sea-stream/p/14262228.html
Copyright © 2011-2022 走看看