Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selenium Learning #1

Open
mayingping-Bella opened this issue Jun 15, 2022 · 1 comment
Open

Selenium Learning #1

mayingping-Bella opened this issue Jun 15, 2022 · 1 comment

Comments

@mayingping-Bella
Copy link
Owner

No description provided.

@mayingping-Bella mayingping-Bella changed the title Selinum Learning Selenium Learning Jun 15, 2022
@mayingping-Bella
Copy link
Owner Author

  1. Refer link:
selenium的使用:https://www.cnblogs.com/xiao-xue-di/p/10932504.html
selenium常用语法:

2. 基本语法:

from selenium import webdriver

browser = webdriver.Chrome()  #声明浏览器对象
browser.get('URL')  #访问页面

3. 查找元素:
find_element(By.ID/CSS_SELETOR/CLASS...., ' ')

4. 常用操作:


- send_keys()   #追加式输入,不是替换式输入
- clear()  # 无参,清空数据
- click()  #无参,点击元素
- select:下拉列表(**需要多研究**)
    - 导入:from selenium.webdriver.support.select import Select
    - 封装Select
  
- 模拟键盘操作:
    - send_keys(Keys.CONTROL, 'a')  #Ctrl + a 全选
    - send_keys(Keys.CONTROL, ‘c’)#Ctrl+c复制
    - send_keys(Keys.CONTROL, ‘v’)#Ctrl+v粘贴
    - send_keys(Keys.CONTROL, ‘a’, Keys.DELETE)#删除

- 弹出框操作(需要研究)
- 等待操作:
    - time.sleep() #强制等待
    - driver.impolicitly_wait() #隐式等待
- 切换frame (需要研究)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant