使用硒和Appium是否可以在wifi网络之间进行更改? [英] Using selenium and Appium is it possible to change between wifi networks?

查看:135
本文介绍了使用硒和Appium是否可以在wifi网络之间进行更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用:硒webdriver,rubygems,appium,android和ios设备

Using: selenium webdriver, rubygems, appium, android and ios devices

我正在测试的应用程序具有一个按钮,该按钮仅在连接到特定的无线网络时才启用.我想创建一个脚本来检查按钮是否处于活动状态

The app I am testing has a button which becomes enabled only when connected to a specific wireless network. I'd like to create a script which will check if the button is active or not

  vKioskStatus = element.enabled?
  puts(vKioskStatus)

如果它不处于活动状态,那么我想更改wifi网络.可以自动在移动设备上更改网络吗?

If it is not active, then I'd like to change wifi networks. Is that possible to automate changing networks on a mobile device?

更新

尝试使用getNetworkConnection时收到以下错误.我需要添加一个要求吗?

I'm receiving the following error when trying to use getNetworkConnection. Is there a require I need to add?

<main>': undefined method `getNetworkConnection' for #<Selenium::WebDriver::Driver:0x..fe1a5511e browser=:firefox> (NoMethodError)

这是我的代码:

require 'rubygems'
require 'selenium-webdriver'
require 'uri'
require 'appium_lib'

require_relative 'AndroidLib'
cButton = Buttons.new

driver = Selenium::WebDriver.for(:remote, :url => "http://127.0.0.1:4723/wd/hub") # Works for Android
sleep(5)

bob = driver.getNetworkConnection()
puts bob

推荐答案

您可以使用以下appium命令在Android(iOS中无法使用)中切换wifi连接,

you can toggle the wifi connection in Android (not possible in iOS) using the below appium commands,

要启用飞行模式:

# Python

def enableFlightMode(self,context):
        driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)
        driver.implicitly_wait(10)
        if driver.network_connection == 1:
            self.report_pass("The network connection is disabled in the mobile and flight mode is active.")
        else:
            self.report_fail("The flight mode is not active yet!")

并禁用飞行模式:

def enableFlightMode(self,context):
        driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)
        driver.implicitly_wait(10)
        if driver.network_connection == 1:
            self.report_pass("The network connection is disabled in the mobile and flight mode is active.")
        else:
            self.report_fail("The flight mode is not active yet!")

这篇关于使用硒和Appium是否可以在wifi网络之间进行更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆