关于使用Appium(selenium)+ruby来进行手机端浏览器的自动化测试的启动和执行

(1)appium配置文件

IOS如下:

platformName="ios"

platformVersion ="12.4"

deviceName ="iphone 6plus"

automationName='XCUITest

Udid="your iphone's UDID"app=""

browserName ="Safari"

newCommandTimeout =50000

ANdroid如下:

platformName="android"

platformVersion="9.0"

deviceName ="Huawei X40"

automationName ="UiAutomator2"

udid ="your mobile's UDID"

app=""

browserName=“浏览器名字chrome,firefox等”

newCommandTimeout =60000

[chromeOptions]w3c="false"

(2)启动driver

caps = Appium.load_appium_txt(file:File.expand_path(File.join(__dir__,./appium.txt')), verbose:true)appium_url='http://localhost:4723/wd/hub

Driver = Appium::Core.for(url:appium_url, desired_capabilities: caps).start_driver

(3)Driver启动之后,我们的case中会有一些需要上传图片,但是手机native的元素无法通过Driver默认获取,所以需要

Driver.available_contexts:是用来获取所有的context,一般默认为默认的webview context 也就是我们当前浏览器的context。

Driver.current_context:是用来获取当前的context

Driver.set_context(context):是用来switch context,例如我们默认的是当前浏览器的wEBvIEw,我们需要switch to NATIVE APP来获取native相关的元素,我们就可以

Driver.set_context("NATIVE APp")

这样我们就可以通过断点,appium来定位手机native的元素了~

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容