美文网首页
macaca初体验

macaca初体验

作者: dittoyy3991 | 来源:发表于2017-07-20 17:51 被阅读158次

感叹下~
虫师真的是走在技术前沿啊,最近火的东西他去年就已经接触了,不愧是大师级测试元老

macaca==马擦擦???喵喵喵

主要三个链接齁~
幸好之前装过nodejs~~~

wd-python

虫师web-macaca

macaca官网的demo嗷

听说api和selenium差不多,松了一口气,不然以为要学的还有好多好多~
今天不想学习了,下次再来研究你,哼~
macaca server --verbose

#coding:utf-8

import unittest
import time
from macaca import WebDriver

desired_caps = {
    'platformName': 'desktop',
    'browserName': 'electron'
}

server_url = {
    'hostname': 'localhost',
    'port': 3456
}

class MacacaTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.driver = WebDriver(desired_caps, server_url)
        cls.driver.init()

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    def test_get_url(self):
        self.driver                     \
          .set_window_size(1280, 800)   \
          .get('https://www.baidu.com')

    def test_search_macaca(self):
        self.driver              \
            .element_by_id('kw') \
            .send_keys('macaca')
        self.driver              \
            .element_by_id('su') \
            .click()
        time.sleep(3)
        html = self.driver.source
        self.assertTrue('macaca' in html)
        self.assertTrue(
          self.driver.element_by_css_selector_if_exists(
            '#head > div.head_wrapper'))
        self.driver                                    \
            .element_by_xpath_or_none('//*[@id="kw"]') \
            .send_keys(' elementByXPath')
        self.driver              \
            .element_by_id('su') \
            .click()
        self.driver.take_screenshot()


if __name__ == '__main__':
    unittest.main()

yaml 一定要搞定这个神器啊,开发说因为它很酷

os:
  - osx
  - linux
env:
  - TEST_SUITE=ios
  - TEST_SUITE=android
  - TEST_SUITE=pc-browser
matrix:
    fast_finish: true
    exclude:
      - os: osx
        env: TEST_SUITE=ios
      - os: osx
        env: TEST_SUITE=android
      - os: osx
        env: TEST_SUITE=pc-browser
      - os: linux
        env: TEST_SUITE=ios
      - os: linux
        env: TEST_SUITE=android
      - os: linux
        env: TEST_SUITE=pc-browser
    include:
      - os: osx
        env: TEST_SUITE=ios
        osx_image: xcode8.3
        language: generic
        before_install:
          - brew update
          - brew install carthage > /dev/null 2>&1
          - brew install ios-webkit-debug-proxy > /dev/null 2>&1
          - brew install nvm > /dev/null 2>&1
          - brew install python3
          - pip install virtualenv
          - virtualenv env -p python3
          - source env/bin/activate
        install:
          - echo Hello Macaca!
          - source $(brew --prefix nvm)/nvm.sh
          - nvm install 7
          - nvm use 7
          - npm i ios-simulator macaca-cli macaca-ios -g
          - open -a Simulator --args -CurrentDeviceUDID `ios-simulator -n 'iPhone 6s'` > /dev/null 2>&1
          - pip install -r requirements.txt
        script:
          - macaca server --verbose &
          - sleep 10
          - python tests/macaca-ios-sample.test.py
      - os: linux
        env: TEST_SUITE=android
        jdk: oraclejdk8
        language: android
        android:
          components:
            - tools
            - build-tools-25.0.2
            - platform-tools
            - extra-android-m2repository
            - extra-google-android-support
            - android-25
        sudo: required
        addons:
          apt:
            sources:
              - deadsnakes
            packages:
              - python3.5
        before_install:
          - export CHROME_BIN=chromium-browser
          - wget http://services.gradle.org/distributions/gradle-3.3-all.zip
          - unzip gradle-3.3-all.zip > /dev/null
          - export GRADLE_HOME=$PWD/gradle-3.3
          - export PATH=$GRADLE_HOME/bin:$PATH
          - export JAVA_HOME=/usr/lib/jvm/java-8-oracle
          - export ANDROID_HOME=/usr/local/android-sdk
          - . $HOME/.nvm/nvm.sh
          - export DISPLAY=:99.0
          - sh -e /etc/init.d/xvfb start
        before_script:
          - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
          - emulator -avd test -no-audio -no-window &
          - android-wait-for-emulator
          - adb shell input keyevent 82 &
        install:
          - echo Hello Macaca!
          - nvm install 7
          - nvm use 7
          - npm install -g macaca-cli macaca-android
          - pip install virtualenv
          - virtualenv env -p python3.5
          - source env/bin/activate
          - pip install -r requirements.txt
        script:
          - macaca server --verbose &
          - sleep 10
          - python3 tests/macaca-android-sample.test.py
      - os: linux
        env:
          - TEST_SUITE=pc-browser
        language: python
        sudo: false
        python: "3.5"
        addons:
          apt:
            packages:
              - xvfb
        before_install:
          - . $HOME/.nvm/nvm.sh
          - export DISPLAY=':99.0'
          - Xvfb :99 -screen 0 1366x768x24 > /dev/null 2>&1 &
        install:
          - echo Hello Macaca!
          - nvm install 7
          - nvm use 7
          - npm install -g macaca-cli macaca-electron
          - pip install -r requirements.txt
        script:
          - macaca server --verbose &
          - sleep 10
          - python3 tests/macaca-desktop-sample.test.py
electro-chrome

还有个https://testerhome.com/topics/4644

相关文章

  • macaca初体验

    感叹下~虫师真的是走在技术前沿啊,最近火的东西他去年就已经接触了,不愧是大师级测试元老 macaca==马擦擦??...

  • Macaca初体验-PC端(Python)

    前言: Macaca 是一套面向用户端软件的测试解决方案,提供了自动化驱动,周边工具,集成方案。由阿里巴巴公司开源...

  • Macaca初体验-Android端(Python)

    前言: Macaca 是一套面向用户端软件的测试解决方案,提供了自动化驱动,周边工具,集成方案。由阿里巴巴公司开源...

  • Macaca 极简教程

    Macaca 介绍 源码空间:https://github.com/macacajs 模块拆分讲解: Macaca...

  • Macaca的介绍安装使用

    Macaca介绍 Macaca的基本组成 通过对源码各个模块的分析,可以帮助我们对Macaca的整体构成有一个基础...

  • macaca(一) windows下环境搭建

    macaca 喜欢你就点这里 1、macaca 是啥呢 macaca是一套自动化解决方案,支持支持主流的移动技术...

  • Macaca简单入门

    执行Macaca自动化脚本时,首先需要启动一个Macaca服务器: 参数设置 启动Macaca服务器时如果没有指定...

  • 自动化测试Macaca

    Macaca简介: Macaca是由阿里巴巴公司开发的一套自动化解决方案,适用于PC端和移动端。 Macaca P...

  • macaca原理

    AndroidMacaca针对安卓平台的驱动集合 macaca-android 安卓驱动macaca-adb 封装...

  • macaca(二) sample demo

    先来个macaca源码地址吧!source code macaca都是开源的呀!!!好赞 一、java sampl...

网友评论

      本文标题:macaca初体验

      本文链接:https://www.haomeiwen.com/subject/nerjkxtx.html