【求助】appium自动化测试中,遇到向雪球搜索框输入内容,经常出现没有弹出相关搜索内容的问题,导致无法找到搜索元素就报错失败了。请问这个问题是因为send_keys()方法的问题,还是雪球APP自己的问题?

代码:
“”"
参数化用例
测试搜索功能,输入多个参数测试
“”"

import pytest
import time
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from hamcrest import *

class TestSearchFunc:
def setup(self):
desire_cap = {
“platformName”: “android”,
“deviceName”: “c02eda2b”,
“appPackage”: “com.xueqiu.android”,
“appActivity”: “.view.WelcomeActivityAlias”,
“noReset”: “true”,
“dontStopAppOnReset”: “true”,
“skipDeviceInitialization”: “true”
}
self.driver = webdriver.Remote(“http://127.0.0.1:4723/wd/hub”, desire_cap)
self.driver.implicitly_wait(10)

def teardown(self):
    self.driver.find_element(MobileBy.ID, "com.xueqiu.android:id/action_close").click()
    pass

@pytest.mark.parametrize('searchkey, stock_num, expected_price', [
    ('阿里巴巴', 'BABA', 210),
    ('小米', '01810', 25),
])
def test_search(self, searchkey, stock_num, expected_price):
    self.driver.find_element(MobileBy.ID, "com.xueqiu.android:id/home_search").click()
    self.driver.find_element(MobileBy.ID, "com.xueqiu.android:id/search_input_text").send_keys(searchkey)
    self.driver.find_element(MobileBy.ID, "com.xueqiu.android:id/name").click()
    #print(stock_num)
    current_price = float(self.driver.find_element(MobileBy.XPATH, f"//*[@text='{stock_num}']/../../..//*[@resource-id='com.xueqiu.android:id/current_price']").text)
    assert_that(current_price, close_to(expected_price, expected_price*0.1))
    print(current_price)

报错信息:

  raise exception_class(message, screen, stacktrace)

E selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
app图片:

先在输入框点击一下,然后send_keys呢

不行,一样的

报啥错

手动输入正常吗?

这个错误,找不到元素。

手动在雪球上键入是正常的,没出现过该问题。之前以为是等待时间是不是太短了,隐式等待时间修改为10s,依然存在该问题。

关闭