测试积点老人 发表于 2019-10-24 10:24:42

Python自动控制打电话,运行不成功,求助帖

我在运行过程中,没有报错,运行结果却是一串数字
如图:

#源码如下:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from appium.webdriver.common.touch_action import TouchAction



byDict = {
    "xpath": By.XPATH,
    "id": By.ID,
}

class Action:
    new_desired_caps = {}

    @property
    def url(self):
      return self.new_url

    @url.setter
    def url(self, ip):
      self.new_url = 'http://{ip}:4723/wd/hub'.format(ip=ip)

    @property
    def driver(self):
      return self.new_driver

    @driver.setter
    def driver(self, driver):
      self.new_driver = driver
      self.new_touch = TouchAction(self.new_driver)

    @property
    def touch(self):
      return self.new_touch

    @property
    def desired_caps(self):
      return self.new_desired_caps

    @desired_caps.setter
    def desired_caps(self, desired_caps):
      self.new_desired_caps = desired_caps

    def find_ele(self, loc):
      print(loc.split("=>"),loc.split("=>"))
      element = WebDriverWait(self.driver, 30).until(
            lambda x: x.find_element(byDict], loc.split("=>")))
      print(element)
      return element


    def click_key(self, loc):
      self.find_ele(loc).click()


if __name__ == '__main__':
    # a = Action()
    b = eval('10*(1-10*0.01)*908.35*0.0001')
    print(b)


#运行程序:
appconfig = (5,'com.android.contacts','com.android.contacts.activities.DialtactsActivity',1,1,1,"{'androidProcess': 'com.tencent.mm:tools'}",1, 'CUN-AL00')
phone = (8, 'myphone', 'CUN-AL00', 'Android', 'CYSBBBE710517072', '5.1')
print(appconfig)
print(phone)

import sys
sys.path.insert(0,"D:\\Python\\source\\python_call")
from action import Action
from appium import webdriver

action = Action()
# 相关配置
action.desired_caps['platformName'] = 'Android'            # 平台
action.desired_caps['platformVersion'] = '5.1'               # Android版本
action.desired_caps['deviceName'] = 'CYSBBBE710517072'          # 设备号
action.desired_caps['appPackage'] = 'com.android.contacts'   # 包名
action.desired_caps['appActivity'] = 'com.android.contacts.activities.DialtactsActivity'# 启动页
action.desired_caps['unicodeKeyboard'] = True                # 使用unicode编码方式发送字符串
action.desired_caps['resetKeyboard'] = True                  # 将键盘隐藏起来,默认true
action.desired_caps['noReset'] = True                        # 应用状态是否需要重置,默认true
action.desired_caps['automationName'] = 'Uiautomator2'       # 自动化引擎,兼容原生和H5

# 控制远程appium
action.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", action.desired_caps)

# 点击事件
action.click_key("id=>one")
action.click_key("id=>five")
action.click_key("id=>two")
action.click_key("id=>three")
action.click_key("id=>six")
action.click_key("id=>two")
action.click_key("id=>eight")
action.click_key("id=>eight")
action.click_key("id=>eight")
action.click_key("id=>star")
action.click_key("id=>star")
action.click_key("id=>dctv_call")

bellas 发表于 2019-10-25 09:23:28

是不是事件写错了

jingzizx 发表于 2019-10-25 10:07:39

单步调试

qqq911 发表于 2019-10-25 10:45:21

检查下代码
页: [1]
查看完整版本: Python自动控制打电话,运行不成功,求助帖