感叹下~
虫师真的是走在技术前沿啊,最近火的东西他去年就已经接触了,不愧是大师级测试元老
macaca==马擦擦???喵喵喵
主要三个链接齁~
幸好之前装过nodejs~~~
听说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
网友评论