SeleniumIDE的下载安装

SeleniumIDE的下载安装

官网https://www.selenium.dev/
Chrome插件https://chrome.google.com/webstore/detail/selenium-ide/mooikfkahbdckldjjndioackbalphokd
Firefox插件Selenium IDE – Get this Extension for :fox_face: Firefox (en-US)
github releasehttps://github.com/SeleniumHQ/selenium-ide/releases
其它版本Selenium IDE version history - 1 version – Add-ons for Firefox (en-GB)
注意:Chrome插件在国内无法下载(需要翻墙或者代理),Firefox可以直接下载。

SeleniumIDE的启动

  • 安装完成后,通过在浏览器的菜单栏中点击它的图标来启动它;
  • 如果没看到图标,首先确保是否安装了Selenium IDE扩展插件;
  • 通过以下链接访问所有插件:
    • Chrome: chrome://extensions
    • Firefox: about:addons

SeleniumIDE的常用功能


①新建、保存、打开
②开始和停止录制
③运行8中的所有的实例
④运行单个实例
⑤调试模式
⑥调整案例的运行速度
⑦要录制的网址
⑧实例列表
⑨动作、目标、值
⑩对单条命令的解释
⑪运行日志

录制实例:


导出代码:

# Generated by Selenium IDE
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class TestDefaultSuite():
  def setup_method(self, method):
    self.driver = webdriver.Chrome()
    self.vars = {}
  
  def teardown_method(self, method):
    self.driver.quit()
  
  def test_baidu(self):
    self.driver.get("https://www.baidu.com/")
    self.driver.set_window_size(958, 680)
    self.driver.find_element(By.ID, "kw").click()
    self.driver.find_element(By.ID, "kw").click()
    self.driver.find_element(By.ID, "kw").send_keys("python")
    self.driver.find_element(By.CSS_SELECTOR, ".bdsug-s").click()
    element = self.driver.find_element(By.ID, "su")
    actions = ActionChains(self.driver)
    actions.move_to_element(element).perform()
    self.driver.find_element(By.ID, "su").click()
    self.driver.find_element(By.ID, "su").click()
    element = self.driver.find_element(By.CSS_SELECTOR, "body")
    actions = ActionChains(self.driver)
    actions.move_to_element(element, 0, 0).perform()