• 作业2

    class Test_api():
    logging.basicConfig(level=logging.INFO)
    def test_xueqiu_quote(self):
    url='https://stock.xueqiu.com/v5/stock/portfolio/stock/list.json'
    param={'category':'2'}
    cookies={'u': '3446260779', 'xq_a_token': '5806a70c6bc5d5fb2b00978aeb1895532fffe502'}
    headers={'User-Agent': 'Xueqiu Android 11.19'}
    r = requests.get(url=url,
    params=param,
    cookies=cookies,
    headers=headers
    )
    logging.info(r.text)
    logging.info(r.content)
    logging.info(json.dumps(r.json(), indent=2))
    assert r.json()['data']['category'] == 2
  • 1.如果WDA能把应用启动起来,就说明WDA环境没问题
    2.ios12.X支持swipe和tap
    3.根据你的log截图,应该是你swipe参数给错了

  • 想学习cookie的处理

  • 作业

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys


    class Test_Xueqiu_web(object):
    def setup_method(self):
    url = "https://xueqiu.com/"
    self.driver = webdriver.Chrome()
    self.driver.implicitly_wait(20)
    self.driver.get(url)

    def teardown_method(self):
    self.driver.quit()

    def test_xueqiu_web(self):
    search_field = self.driver.find_element_by_xpath('//*[@placeholder="搜索"]')
    search_field.send_keys('阿里巴巴')
    search_field.send_keys(Keys.ENTER) #模拟键盘上的enter
    self.driver.find_element_by_xpath('//*[text()[contains(.,"01688")]]/../../../..//*[@class="follow__control"]').click()
    self.driver.find_element_by_name('username').send_keys('158716867865')
    self.driver.find_element_by_name('password').send_keys('344545')
    self.driver.find_element_by_xpath('\\*[@class="modal__login__btn"]').click()
  • YAML和.config还有.conftest用哪个做配置文件比较方便

  • 为啥class要继承object

  • capbility 怎么设置成配置文件,让其他用例都调用它

  • 如何能做到用例执行失败,就立马调用截图方法和driver.quit(),我一旦找不到页面元素,它就卡在当前页面了,执行下一个用例也还是那个页面,没有重启:(

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

    提示是没有找到元素

  • 下午我试了有些界面跳转后,隐形等待也不行,得强制等待(time.sleep()),一般是什么原因。