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")

  • 相关阅读:
    文件系统操作与磁盘管理
    文件打包与解压缩
    环境变量与文件查找
    Linux目录结构及文件基本操作
    vim3
    vim2
    vim1
    用户管理
    初识
    第一章
  • 原文地址:https://www.cnblogs.com/sea-stream/p/14262228.html
Copyright © 2011-2022 走看看