51Testing软件测试论坛

标题: 关于playwright #python#的问题:超时后报错 [打印本页]

作者: 测试积点老人    时间: 2021-8-13 11:21
标题: 关于playwright #python#的问题:超时后报错
代码如下

  1. from playwright.sync_api import sync_playwright
  2. with sync_playwright() as p:
  3.     browser = p.chromium.launch(headless=False)
  4.     context = browser.new_context()
  5.     page = context.new_page()
  6.     list1 = ['Russian Federation','United States','Canada','Spain','France','United Kingdom','Netherlands','Israel','Brazil','Chile','Australia','Ukraine','Belarus','Japan','Thailand','Singapore','South Korea','Indonesia','Malaysia','Philippines','Vietnam','Italy','Germany','Saudi Arabia','United Arab Emirates','Poland','Turkey','Portugal']
  7.     print(list1[0])
  8.     page.goto("https://www.aliexpress.com/item/1005001955136541.html")
  9.     print(page.inner_text("#root > div > div.product-main > div > div.product-info > div.product-price > div.product-price-current > span"))
  10.     for i in list1:
  11.         print(i)
  12.         page.click("#root > div > div.product-main > div > div.product-info > div.product-shipping > span.product-shipping-info.black-link")
  13.         page.click("body > div.next-overlay-wrapper.opened > div.next-overlay-inner.next-dialog-container > div > div.next-dialog-body > div > div.address > span > span > span > span.next-select-values.next-input-text-field")
  14.         page.fill("#ae-search-select-1", i)
  15.         page.click("body > div.next-overlay-wrapper.opened > div.next-overlay-inner.next-dialog-container > div > div.next-dialog-body > div > div.address > span > div > div > div > ul > li:nth-child(1) > div")
  16.         with page.expect_navigation():
  17.             page.click("body > div.next-overlay-wrapper.opened > div.next-overlay-inner.next-dialog-container > div > div.next-dialog-footer.next-align-center > button")
  18.         print(page.inner_text("#root > div > div.product-main > div > div.product-info > div.product-price > div.product-price-current > span"))
  19.     browser.close()
复制代码
暴力通过选择器点击,
[attach]133788[/attach]
卡在点击apply的时候,自己点击就会继续运行,直到再次卡住。
[attach]133789[/attach]
没搞懂为什么会卡住。超时后报错
[attach]133790[/attach]



作者: 海海豚    时间: 2021-8-16 09:53
https://blog.csdn.net/zx520113/article/details/103961128/   参考下
作者: bellas    时间: 2021-8-16 10:19
参考下这个链接https://www.zhihu.com/question/264956322
作者: qqq911    时间: 2021-8-16 11:00
下个断点看看




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2