zoukankan      html  css  js  c++  java
  • Automagica小试

    一、概述

    Automagica 是一个开源智能机器人流程自动化(SRPA,Smart Robotic Process Automation)平台,借助 Automagica 的python 函数库,可以通过简单程序脚本实现打开各种应用程序并对应用进行操作的功能,使自动化跨平台流程变得轻而易举。

    环境要求

    Automagica 需要 Python 3.7 环境,官方支持 Windows 10 平台,Linux 和 Mac 目前官方还不支持。

    安装

    pip3 install automagica
    pip3 install selenium

    下文的demo会用到selenium,因此先安装一下。

    二、演示

    业务场景

    实验案例的业务场景是:自动打开Chrome浏览器,跳转到百度首页,然后检索关键字“automagica”。

    chromedriver安装

    查看浏览器版本

    1. 打开谷歌浏览器, 在地址栏输入 chrome://version/ 查看版本信息:

    2. 选择合适版本的驱动下载

    下载地址:http://chromedriver.storage.googleapis.com/index.html

     由于我的版本为:75.0.3770.100,但是这里并没有与之对应的版本。因此选择小一点的版本,也就是:75.0.3770.90

    3. 解压下载的驱动放到指定目录,代码调用时指定该目录即可。

    这里,我将chromedriver.exe放到路径 E:virtualenvdjango下面。

    完整代码

    test1.py

    #!/usr/bin/python
    # -*- coding: UTF-8 -*-
    
    
    # 引用automagica的核心库,鼠标、键盘、浏览器、系统应用、Office、PDF等操作函数,都依赖于该模块。
    from automagica import *
    # 引入selenium 模块
    from selenium import webdriver
    
    # chromedriver 驱动路径
    chrome_driver = r"E:virtualenvdjangochromedriver.exe"
    # #创建chrome浏览器实例,指定驱动
    browser = webdriver.Chrome(executable_path=chrome_driver)
    # 打开百度
    browser.get('https://baidu.com/')
    # 获取搜索输入框,嵌入关键字automagica
    search_input = browser.find_element_by_name('wd')
    search_input.send_keys("automagica")
    # 获取检索按钮,点击
    search_btn = browser.find_element_by_id('su')
    search_btn.click()

    注意:这里必须指定chromedriver 驱动路径,否则会出现错误:

    selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH

    虽然我尝试将此路径加入到windows 环境变量pah中,但测试之后,还是会报错。

    运行代码,效果如下:

    本文参考链接:

    https://www.cnblogs.com/vikezhu/p/12343982.html

    https://blog.csdn.net/weixin_43746433/article/details/95237254

  • 相关阅读:
    10月15日模拟赛题解
    NOIp初赛题目整理
    【meet in the mid】【qbxt2019csp刷题班day1C】birthday
    【字符串】 manacher算法
    【border树】【P2375】动物园
    【border相关】【P3426】 [POI2005]SZA-Template
    【字符串】 Z-algorithm
    【字符串】KMP
    【神奇性质】【P5523】D [yLOI2019] 珍珠
    【线段树】【P5522】[yLOI2019] 棠梨煎雪
  • 原文地址:https://www.cnblogs.com/xiao987334176/p/13410783.html
Copyright © 2011-2022 走看看