折腾:
【未解决】iOS自动化安装app:给当前WiFi去掉代理以及自动安装app后再恢复之前代理
期间,已经可以进去WiFi详情页。
现在需要去找到 代理设置 并点击后面的按钮,进去配置代理页面。
已经进去了WiFi的详情页:

xml
<XCUIElementTypeTable type="XCUIElementTypeTable" enabled="true" visible="true" x="0" y="0" width="414" height="736"> 。。。 <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="657" width="414" height="39"> <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="HTTP 代理" name="HTTP 代理" label="HTTP 代理" enabled="true" visible="true" x="0" y="657" width="414" height="39"/> </XCUIElementTypeOther> <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" visible="true" x="0" y="695" width="414" height="46"> <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="695" width="414" height="1"/> <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" x="0" y="740" width="414" height="1"/> <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="配置代理" name="配置代理" label="配置代理" enabled="true" visible="true" x="20" y="708" width="70" height="21"/> <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="关闭" name="关闭" label="关闭" enabled="true" visible="true" x="341" y="708" width="35" height="21"/> <XCUIElementTypeButton type="XCUIElementTypeButton" name="更多信息" label="更多信息" enabled="false" visible="true" x="386" y="711" width="8" height="14"/> </XCUIElementTypeCell>
以及:
自己单独手动去设置加上代理后:
在此之前,看看当前Mac中的IP:
~ ifconfig | grep 192. inet 192.168.31.46 netmask 0xffffff00 broadcast 192.168.31.255
是192.168.31.46
设置后是:

<XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" visible="true" x="0" y="695" width="414" height="46"> <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="695" width="414" height="1"/> <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" x="0" y="740" width="414" height="1"/> <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="配置代理" name="配置代理" label="配置代理" enabled="true" visible="true" x="20" y="708" width="70" height="21"/> <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="手动" name="手动" label="手动" enabled="true" visible="true" x="341" y="708" width="35" height="21"/> <XCUIElementTypeButton type="XCUIElementTypeButton" name="更多信息" label="更多信息" enabled="false" visible="true" x="386" y="711" width="8" height="14"/> </XCUIElementTypeCell>
然后就可以接着去写代码了:
此处没法wda去query,又只能用bs的find
"""
设置 无线局域网 详情页 代理 关闭:
<XCUIElementTypeTable type="XCUIElementTypeTable" enabled="true" visible="true" x="0" y="0" width="414" height="736">
。。。
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="657" width="414" height="39">
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="HTTP 代理" name="HTTP 代理" label="HTTP 代理" enabled="true" visible="true" x="0" y="657" width="414" height="39"/>
</XCUIElementTypeOther>
<XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" visible="true" x="0" y="695" width="414" height="46">
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="695" width="414" height="1"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" x="0" y="740" width="414" height="1"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="配置代理" name="配置代理" label="配置代理" enabled="true" visible="true" x="20" y="708" width="70" height="21"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="关闭" name="关闭" label="关闭" enabled="true" visible="true" x="341" y="708" width="35" height="21"/>
<XCUIElementTypeButton type="XCUIElementTypeButton" name="更多信息" label="更多信息" enabled="false" visible="true" x="386" y="711" width="8" height="14"/>
</XCUIElementTypeCell>
设置 无线局域网 详情页 代理 手动:
<XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" visible="true" x="0" y="695" width="414" height="46">
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="695" width="414" height="1"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" x="0" y="740" width="414" height="1"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="配置代理" name="配置代理" label="配置代理" enabled="true" visible="true" x="20" y="708" width="70" height="21"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="手动" name="手动" label="手动" enabled="true" visible="true" x="341" y="708" width="35" height="21"/>
<XCUIElementTypeButton type="XCUIElementTypeButton" name="更多信息" label="更多信息" enabled="false" visible="true" x="386" y="711" width="8" height="14"/>
</XCUIElementTypeCell>
"""
curPageXml = self.get_page_source()
soup = CommonUtils.xmlToSoup(curPageXml)
configProxyChainList = [
{
"tag": "XCUIElementTypeTable",
"attrs": self.FullScreenAttrDict
},
{
"tag": "XCUIElementTypeCell",
"attrs": {"enabled":"true", "visible":"true", "x":"0", "width":"%s" % self.X}
},
{
"tag": "XCUIElementTypeStaticText",
"attrs": {"enabled":"true", "visible":"true", "value": "配置代理"}
},
]
configProxySoup = CommonUtils.bsChainFind(soup, configProxyChainList)
if not configProxySoup:
respInfo = "Not find 配置代理 in connected WiFi detail page"
return isProcessdOk, respInfo
parentCellSoup = configProxySoup.parent
proxyValueP =
re.compile
("(手动)|(自动)|(关闭)")
proxyValueSoup = parentCellSoup.find(
'XCUIElementTypeStaticText',
attrs={"type": "XCUIElementTypeStaticText", "value": proxyValueP, "enabled":"true", "visible":"true"},
)
if not proxyValueSoup:
respInfo = "Not find current value of proxy config"
return isProcessdOk, respInfo
proxySoupAttrDict = proxyValueSoup.attrs
currentProxyValue = proxySoupAttrDict.get("value")
if currentProxyValue == "关闭":
# no need change proxy
isProcessdOk = True
respInfo = None # means no proxy
return isProcessdOk, respInfo
elif currentProxyValue == "手动":
# need into config page, to get it value, then reconfig to 关闭
clickedOk = self.clickElementCenterPosition(proxyValueSoup)
if not clickedOk:
respInfo = "Fail to click 配置代理 当前值:%s" % currentProxyValue
return isProcessdOk, respInfo
else:
# currentProxyValue == "自动"
respInfo = "Not support of current proxy config value %s" % currentProxyValue
return isProcessdOk, respInfo先写这些,去调试

可以找到 配置代理

能找到此处的 手动

可以点击 手动 进入 配置代理 页面。
然后:
【未解决】iOS自动处理WiFi代理:配置代理页中从手动切换到关闭
【后记20200610】
再去整理优化成独立函数:
def iOSGetCurrentWiFiProxyType(self):
"""from WiFi detail page, get current proxy config type value"""
proxyTypeSoup = None
"""
设置 无线局域网 详情页 代理 关闭:
<XCUIElementTypeTable type="XCUIElementTypeTable" enabled="true" visible="true" x="0" y="0" width="414" height="736">
。。。
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="657" width="414" height="39">
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="HTTP 代理" name="HTTP 代理" label="HTTP 代理" enabled="true" visible="true" x="0" y="657" width="414" height="39"/>
</XCUIElementTypeOther>
<XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" visible="true" x="0" y="695" width="414" height="46">
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="695" width="414" height="1"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" x="0" y="740" width="414" height="1"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="配置代理" name="配置代理" label="配置代理" enabled="true" visible="true" x="20" y="708" width="70" height="21"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="关闭" name="关闭" label="关闭" enabled="true" visible="true" x="341" y="708" width="35" height="21"/>
<XCUIElementTypeButton type="XCUIElementTypeButton" name="更多信息" label="更多信息" enabled="false" visible="true" x="386" y="711" width="8" height="14"/>
</XCUIElementTypeCell>
设置 无线局域网 详情页 代理 手动:
<XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" visible="true" x="0" y="695" width="414" height="46">
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" x="0" y="695" width="414" height="1"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" x="0" y="740" width="414" height="1"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="配置代理" name="配置代理" label="配置代理" enabled="true" visible="true" x="20" y="708" width="70" height="21"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="手动" name="手动" label="手动" enabled="true" visible="true" x="341" y="708" width="35" height="21"/>
<XCUIElementTypeButton type="XCUIElementTypeButton" name="更多信息" label="更多信息" enabled="false" visible="true" x="386" y="711" width="8" height="14"/>
</XCUIElementTypeCell>
"""
curPageXml = self.get_page_source()
soup = CommonUtils.xmlToSoup(curPageXml)
configProxyChainList = [
{
"tag": "XCUIElementTypeTable",
"attrs": self.FullScreenAttrDict
},
{
"tag": "XCUIElementTypeCell",
"attrs": {"enabled":"true", "visible":"true", "x":"0", "width":"%s" % self.X}
},
{
"tag": "XCUIElementTypeStaticText",
"attrs": {"enabled":"true", "visible":"true", "value": "配置代理"}
},
]
configProxySoup = CommonUtils.bsChainFind(soup, configProxyChainList)
if configProxySoup:
parentCellSoup = configProxySoup.parent
proxyTypeP = re.compile("(手动)|(自动)|(关闭)")
proxyTypeSoup = parentCellSoup.find(
'XCUIElementTypeStaticText',
attrs={"type": "XCUIElementTypeStaticText", "value": proxyTypeP, "enabled":"true", "visible":"true"},
)
return proxyTypeSoup调用:
proxyTypeSoup = self.iOSGetCurrentWiFiProxyType() if not proxyTypeSoup: respInfo = "Not find current WiFi proxy config type" return isProcessdOk, respInfo
即可。