3-元素定位练习

进入boss直聘搜索某职位,并进入第一个搜索结果,打印其工作地点、年限、学历信息

from appium import webdriver
from config import url,desired_Caps

driver = webdriver.Remote(url,desired_Caps)
driver.implicitly_wait(10)
# 点击搜索按钮
search_btn = driver.find_elements_by_id('com.hpbr.bosszhipin:id/img_icon')[-1].click()

#输入搜索文本
search_text = driver.find_element_by_id('com.hpbr.bosszhipin:id/et_search').send_keys('自动化测试')

# 选中联想出的搜索词汇
search_key = driver.find_element_by_id('com.hpbr.bosszhipin:id/tv_filtered_name').click()

# 选中第一个搜索结果,进入详情
jobs_card = driver.find_elements_by_id('com.hpbr.bosszhipin:id/view_job_card')[0].click()
# 工作地区、年限、学历
job_location = driver.find_element_by_xpath('//*[@resource-id="com.hpbr.bosszhipin:id/prior_layout"]/*[1]').text
job_work_exp = driver.find_element_by_xpath('//*[@resource-id="com.hpbr.bosszhipin:id/prior_layout"]/*[2]').text
job_degree = driver.find_element_by_xpath('//*[@resource-id="com.hpbr.bosszhipin:id/prior_layout"]/*[3]').text

# 打印工作地区、年限、学历
print(f'工作地区:{job_location} 年限{job_work_exp}  学历{job_degree}')

cofig.py

url = 'http://127.0.0.1:4723/wd/hub'
desired_Caps={
    
    
    # 1、移动设备平台名、版本号
    'platformName': 'Android',
    'platformVersion': '10',

    # 2、设备名称
    'deviceName': 'xianyu',

    # 3、被测app 包名、入口信息
    'appPackage':'com.hpbr.bosszhipin',
    'appActivity':'.module.launcher.WelcomeActivity',

    # 4、设置自动化后不重置app
    'noReset': True,

    # 5、设置session超时时间,单位秒,默认60s
    'newCommandTimeout': 6000,

    # 6、设置底层测试驱动
    'automationName': 'UiAutomator2'
}

打印结果:

工作地区:北京·海淀区·上地 年限3-5年  学历本科

猜你喜欢

转载自blog.csdn.net/weixin_45128456/article/details/114101754
今日推荐