Titans Selenium 自動化框架-百度搜索例子

首先我們要編寫自動化操作命令:

[
  {
    "component": "request",
    "args": {
      "url": "https://www.baidu.com"
    },
    "type": "browser"
  },
  {
    "component": "input",
    "args": {
      "xpath": "//input[@id='kw']",
      "text": "Python"
    },
    "type": "text"
  },
  {
    "component": "click",
    "args": {
      "xpath": "//input[@id='su']"
    }
  },
  {
    "component": "sleep",
    "args": {
      "time": 5
    }
  }
]

上面配置翻譯出來的意思就是

  1. 請求百度 url
  2. input 輸入框填寫 Python 文本
  3. 點擊搜索按鈕
  4. 睡眠等待5秒,防止執行完成後立刻退出瀏覽器無法觀察效果

具體效果:
百度自動化搜索
Titans 框架 Github Page: https://dmf-code.github.io/titans/

Titans 框架 wiki 文檔: https://github.com/dmf-code/titans/wiki

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章