Linux--抓取Appium网站命令
# 获取各命令url地址
curl http://appium.io/docs/en/commands/device/app/is-app-installed/ 2>/dev/null | grep 'href="../../../[a-zA-Z]' | awk -F"\"" '{print $2}' | awk -F"../../.." '{print $2}' | awk -va="http://appium.io/docs/en/commands" '{print a$1}' > command.txt
# 抓取python示例命令
while read line; do curl $line 2>/dev/null | sed ':a ; N;s/\n/ / ; t a ; ' | awk -F "<pre><code class=\"python\">" '{print $2}' | awk -F "</code></pre>" '{print $1}'; done < command.txt > pythoncommand.txt
# 抓取java示例命令
while read line; do curl $line 2>/dev/null | sed ':a ; N;s/\n/ / ; t a ; ' | awk -F "<pre><code class=\"java\">" '{print $2}' | awk -F "</code></pre>" '{print $1}'; done < command.txt > javacommand.txt
java command content:
// TODO
driver.executeScript("mobile: scroll", ImmutableMap.of("direction", "down"));
driver.quit();
driver.back();
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String pageSource = driver.getPageSource();
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
ScreenOrientation orientation = driver.getOrientation();
driver.rotate(ScreenOrientation.LANDSCAPE);
driver.setLocation(new Location(49, 123, 10)); // Must be a driver that implements LocationContext
Set<String> logTypes = driver.manage().logs().getAvailableLogTypes();
LogEntries logEntries = driver.manage().logs().get("driver");
driver.setSetting(Setting.WAIT_FOR_IDLE_TIMEOUT, Duration.ofSeconds(5));
Map<String, Object> settings = driver.getSettings();
MobileElement elementOne = (MobileElement) driver.findElementByAccessibilityId("SomeAccessibilityID"); MobileElement elementTwo = (MobileElement) driver.findElementByClassName("SomeClassName");
List<MobileElement> elementsOne = (MobileElement) driver.findElementsByAccessibilityId("SomeAccessibilityID"); List<MobileElement> elementsTwo = (MobileElement) driver.findElementsByClassName("SomeClassName");
MobileElement el = driver.findElementByAccessibilityId("SomeId"); el.click();
MobileElement element = (MobileElement) driver.findElementByAccessibilityId("SomeAccessibilityID"); element.sendKeys("Hello world!");
MobileElement element = (MobileElement) driver.findElementByAccessibilityId("SomeAccessibilityID"); element.clear();
MobileElement element = (MobileElement) driver.findElementByClassName("SomeClassName"); String elText = element.getText();
List<MobileElement> element = (MobileElement) driver.findElementByAccessibilityId("SomeAccessibilityID"); String tagName = element.getTagName();
List<MobileElement> element = (MobileElement) driver.findElementByAccessibilityId("SomeAccessibilityID"); String tagName = element.getAttribute("content-desc");
MobileElement element = (MobileElement) driver.findElementByAccessibilityId("SomeAccessibilityID"); boolean isEnabled = element.isEnabled();
List<MobileElement> element = (MobileElement) driver.findElementByAccessibilityId("SomeAccessibilityID"); Rectangle rect = element.getRect();
List<MobileElement> element = (MobileElement) driver.findElementById("SomeId"); String cssProperty = element.getCssValue("style");
// Not supported
// Overrides the Java Object .equals method MobileElement elementOne = (MobileElement) driver.findElementByClassName("SomeClassName"); MobileElement elementTwo = (MobileElement) driver.findElementByClassName("SomeOtherClassName"); boolean isEqual = elementOne.equals(elementTwo);
String context = driver.getContext();
Set<String> contextNames = driver.getContextHandles();
Set<String> contextNames = driver.getContextHandles(); driver.context(contextNames.toArray()[1]); // ... driver.context("NATIVE_APP");
Actions action = new Actions(driver); action.moveTo(element, 10, 10); action.perform();
Actions action = new Actions(driver); action.moveTo(element); action.click(); action.perform();
Actions action = new Actions(driver); action.moveTo(element); action.doubleClick(); action.perform();
Actions action = new Actions(driver); action.moveTo(element); action.clickAndHold(); action.perform();
Actions action = new Actions(driver); action.moveTo(element); action.clickAndHold(); action.moveTo(element, 10, 10); action.release(); action.perform();
TouchActions action = new TouchActions(driver); action.doubleTap(element); action.perform();
TouchActions action = new TouchActions(driver); action.down(10, 10); action.move(50, 50); action.perform();
TouchActions action = new TouchActions(driver); action.down(10, 10); action.up(20, 20); action.perform();
TouchActions action = new TouchActions(driver); action.longPress(element); action.perform();
TouchActions action = new TouchActions(driver); action.scroll(element, 10, 100); action.perform();
TouchAction action = new TouchAction(driver); action.press(10, 10); action.moveTo(10, 100); action.release(); action.perform();
WebElement source = (MobileElement) driver.findElementsByAccessibilityId("SomeAccessibilityID"); WebElement target = (MobileElement) driver.findElementsByAccessibilityId("SomeOtherAccessibilityID"); Point source = dragMe.getCenter(); Point target = driver.findElementByAccessibilityId("dropzone").getCenter(); PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger"); Sequence dragNDrop = new Sequence(finger, 1); dragNDrop.addAction(finger.createPointerMove(Duration.ofMillis(0), PointerInput.Origin.viewport(), source.x, source.y)); dragNDrop.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg())); dragNDrop.addAction(finger.createPointerMove(Duration.ofMillis(700), PointerInput.Origin.viewport(),target.x, target.y)); dragNDrop.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg())); driver.perform(Arrays.asList(dragNDrop));
driver.switchTo().window("handle");
driver.close();
String windowHandle = driver.getWindowHandle();
Set<String> windowHandles = driver.getWindowHandles();
Dimension windowSize = driver.manage().window().getSize();
driver.manage().window().setSize(new Dimension(10, 10));
Point windowPosition = driver.manage().window().getPosition();
driver.manage().window().setPosition(new Dimension(10, 10));
driver.manage().window().maximize();
driver.get("http://appium.io/");
String url = driver.getCurrentUrl();
driver.back();
driver.forward();
driver.refresh();
Set<Cookie> allcookies = driver.manage().getCookies();
driver.manage().deleteAllCookies();
driver.switchTo().frame(3);
driver.switchTo().parentFrame();
((JavascriptExecutor) driver).executeAsyncScript("window.setTimeout(arguments[arguments.length - 1], 500);");
((JavascriptExecutor) driver).executeScript("window.setTimeout(arguments[arguments.length - 1], 500);");
python command content:
self.driver.execute_script("mobile: scroll", {'direction': 'down'})
desired_caps = desired_caps = { 'platformName': 'Android', 'platformVersion': '7.0', 'deviceName': 'Android Emulator', 'automationName': 'UiAutomator2', 'app': PATH('/path/to/app') } self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
self.driver.quit()
desired_caps = self.driver.desired_capabilities()
self.driver.set_page_load_timeout(5000)
self.driver.implicitly_wait(5000)
self.driver.set_script_timeout(5000)
orientation = self.driver.orientation()
driver.orientation = "LANDSCAPE"
self.driver.set_location(49, 123, 10)
log_types = driver.log_types();
logs = driver.get_log('driver');
self.driver.get_settings
el = self.driver.find_element_by_accessibility_id('SomeAccessibilityID')
el = self.driver.find_elements_by_accessibility_id('SomeAccessibilityID')
self.driver.find_element_by_accessibility_id('SomeAccessibilityID').send_keys('Hello world!')
self.driver.find_element_by_accessibility_id('SomeAccessibilityID').clear()
el = self.driver.find_element_by_accessibility_id('SomeAccessibilityID') text = el.text
tagName = self.driver.find_element_by_accessibility_id('SomeAccessibilityID').tag_name
tagName = self.driver.find_element_by_accessibility_id('SomeAccessibilityID').get_attribute('content-desc')
self.driver.find_element_by_accessibility_id('SomeAccessibilityID').is_selected()
self.driver.find_element_by_accessibility_id('SomeAccessibilityID').is_enabled()
self.driver.find_element_by_accessibility_id('SomeAccessibilityID').is_displayed()
location = self.driver.find_element_by_accessibility_id('SomeAccessibilityID').location
# Not supported
cssProperty = self.driver.find_element_by_accessibility_id('SomeId').value_of_css_property("style")
# Not supported
el = self.driver.find_element_by_accessibility_id('SomeAccessibilityID') el.submit();
element = driver.switch_to.active_element
# TODO Python sample
context = driver.current_context # or context = driver.context
contexts = driver.contexts
webview = driver.contexts[1] driver.switch_to.context(webview) # ... driver.switch_to.context('NATIVE_APP')
actions = ActionChains(driver) actions.move_to_element(element) actions.click() actions.perform()
actions = ActionChains(driver) actions.move_to_element(element) actions.double_click() actions.perform()
actions = ActionChains(driver) actions.move_to_element(element) actions.click_and_hold() actions.perform()
from appium.webdriver.common.touch_action import TouchAction # ... actions = TouchAction(driver) actions.tap(element) actions.perform()
from appium.webdriver.common.touch_action import TouchAction # ... actions = TouchAction(driver) actions.double_tap(element) actions.perform()
from appium.webdriver.common.touch_action import TouchAction # ... actions = TouchAction(driver) actions.tap_and_hold(element) actions.move(50, 50) actions.perform()
from appium.webdriver.common.touch_action import TouchAction # ... actions = TouchAction(driver) actions.tap_and_hold(20, 20) actions.release(50, 50) actions.perform()
from appium.webdriver.common.touch_action import TouchAction # ... actions = TouchAction(driver) actions.long_press(element) actions.perform()
from appium.webdriver.common.touch_action import TouchAction # ... actions = TouchAction(driver) actions.scroll_from_element(element, 10, 100) actions.scroll(10, 100) actions.perform()
from appium.webdriver.common.touch_action import TouchAction from appium.webdriver.common.multi_action import MultiAction # ... a1 = TouchAction() a1.press(10, 20) a1.move_to(10, 200) a1.release() a2 = TouchAction() a2.press(10, 10) a2.move_to(10, 100) a2.release() ma = MultiAction(self.driver) ma.add(a1, a2) ma.perform()
from appium.webdriver.common.touch_action import TouchAction // ... actions = TouchAction(driver) actions.tap_and_hold(20, 20) actions.move_to(10, 100) actions.release() actions.perform()
self.driver.switch_to.window("handle")
self.driver.close()
window_handle = self.driver.current_window_handle()
window_handles = self.driver.window_handles()
handle_one_size = self.driver.get_window_size() handle_two_size = self.driver.get_window_size("handleName")
self.driver.set_window_size(10, 10)
url = self.driver.current_url()
self.driver.forward()
self.driver.refresh()
cookies = self.driver.get_cookies()
self.driver.add_cookie({name: 'foo', value: 'bar'})
self.driver.delete_all_cookies()
self.driver.switch_to.frame(3)
self.driver.switch_to.parent()
self.driver.execute_async_script(‘document.title’)
self.driver.execute_script(‘document.title’)
Linux--抓取Appium网站命令的更多相关文章
- Python多进程方式抓取基金网站内容的方法分析
因为进程也不是越多越好,我们计划分3个进程执行.意思就是 :把总共要抓取的28页分成三部分. 怎么分呢? # 初始range r = range(1,29) # 步长 step = 10 myList ...
- 使用BurpSuite抓取HTTPS网站的数据包
昨天面试,技术官问到了我如何使用BurpSuite抓取https网站的数据包,一时间没能回答上来(尴尬!).因为以前https网站的数据包我都是用Fiddler抓取的,Fiddlert自动帮我们配置好 ...
- 在Scrapy项目【内外】使用scrapy shell命令抓取 某网站首页的初步情况
Windows 10家庭中文版,Python 3.6.3,Scrapy 1.5.0, 时隔一月,再次玩Scrapy项目,希望这次可以玩的更进一步. 本文展示使用在 Scrapy项目内.项目外scrap ...
- linux抓取top命令中数据的方法
top在linux中是一个非常直观的命令,可以清晰地看到各进程对资源的使用情况. 但是如果你想从top命令展示中提取某些数据出来,如果想当然地使用这句命令: top|grep xxx 就会被卡住, ...
- python3+beautifulSoup4.6抓取某网站小说(四)多线程抓取
上一篇多文章,是二级目录,根目录"小说",二级目录"作品名称",之后就是小说文件. 本篇改造了部分代码,将目录设置为根目录->作者目录->作品目录- ...
- Linux抓包工具tcpdump命令详解
1.简介 用简单的话来定义tcpdump,就是:dump the traffic on a network,根据使用者的定义对网络上的数据包进行截获的包分析工具. tcpdump可以将网络中 ...
- python3+beautifulSoup4.6抓取某网站小说(三)网页分析,BeautifulSoup解析
本章学习内容:将网站上的小说都爬下来,存储到本地. 目标网站:www.cuiweijuxs.com 分析页面,发现一共4步:从主页进入分版打开分页列表.打开分页下所有链接.打开作品页面.打开单章内容. ...
- python3+beautifulSoup4.6抓取某网站小说(一)爬虫初探
本次学习重点: 1.使用urllib的request进行网页请求,获取当前url整版网页内容 2.对于多级抓取,先想好抓取思路,再动手 3.BeautifulSoup获取html网页中的指定内容 4. ...
- 用php实现一个简单的爬虫,抓取电影网站的视频下载地址
昨天没什么事,先看一下电影,就用php写了一个爬虫在视频网站上进行视频下载地址的抓取,这里总结一下抓取过程中遇到的问题 1:通过访问浏览器来执行php脚本这种访问方式其实并不适合用来爬网页,因为要受到 ...
随机推荐
- phpcms首页如加上用户登录的信息?
请看效果图 我用的是cookie的方法,请先打开discuz的文件 \source\function\function_member.php 找到函数function setloginstatus() ...
- mysql中json_replace函数的使用?通过json_replace对json对象的值进行替换
需求描述: 在看mysql中关于json的内容,通过json_replace函数可以实现对json值的替换, 在此记录下. 操作过程: 1.查看带有json数据类型的表 mysql> selec ...
- Go工具和调试详解
https://blog.csdn.net/happyanger6/article/details/78724594/ https://blog.csdn.net/u012210379/article ...
- 多线程二(GCD)代码笔记
// // TWFXViewController.h // Demo_GCD // // Created by Lion User on 12-12-11. // Copyright (c) 2012 ...
- Centos6.3 下使用 Tomcat-6.0.43 非root用户 部署 生产环境 端口转发方式
一.安装JDK环境 方法一. 官方下载链接 http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260 ...
- PHP计算两个绝对路径的相对路径
用PHP计算两个绝对路径的相对路径,该如何求呢? 先根据分隔符切割,然后查找相同 异同点,然后开始有相同点,从相同点结束为止开始拼接剩余部分,没有的话,到达根路径拼接整体. 截图如下: 代码如下: & ...
- iOS Runloop的超级讲解
这是目前看过的最好的一片中文讲解RunLoop的文章,推荐给大家看一下,原文链接:http://blog.ibireme.com/2015/05/18/runloop/ https://segment ...
- XSS payload 大全
收集的一些XSS payload,主要分为五大类,便于查阅. #第一类:Javascript URL <a href="javascript:alert('test')"&g ...
- 学习下新塘M0芯片的下载方法
编程方式多种多样,解释这几种方式的原理,方便做后续的回答: 一.脱机 脱机的意思就是脱离PC机,有很多芯片必须连接PC才能烧录,比如某些FPGA芯片.MCU芯片.NAND Flash芯片等.脱机和在线 ...
- TCP三次握手和四次挥手原理