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

  • 相关阅读:
    03-模板引擎
    C#扩展方法
    DataTable转IHashObjectList
    创建DataTable
    02-一般处理程序基础
    css3相关样式
    css样式
    css基础知识
    表单和HTML5
    表格相关知识
  • 原文地址:https://www.cnblogs.com/sea-stream/p/14262228.html
Copyright © 2011-2022 走看看