Best Python code snippet using playwright-python
_interaction.py
Source: _interaction.py
...328 è¿å主è¦èµæºååºã329 å¨å¤æ¬¡éå®åçæ
åµä¸ï¼å¯¼èªå°ä½¿ç¨ä¸æ¬¡éå®åçååºè¿è¡è§£æã330 å¦æä¸è½è¿åï¼åè¿å nullã331 :param timeout:æ大æä½æ¶é´ä»¥æ¯«ç§ä¸ºåä½ï¼é»è®¤ä¸º 30 ç§ï¼ä¼ é 0 以ç¦ç¨è¶
æ¶ã332 å¯ä»¥ä½¿ç¨ browser_context.set_default_navigation_timeout(timeout)ã333 browser_context.set_default_timeout(timeout)ã334 page.set_default_navigation_timeout(timeout)335 æ page.set_default_timeout(timeout) æ¹æ³æ´æ¹é»è®¤å¼ã336 :param wait_until: <"load"|"domcontentloaded"|"networkidle"> å½è®¤ä¸ºæä½æåæ¶ï¼é»è®¤å è½½ã äºä»¶å¯ä»¥æ¯ï¼#337 'domcontentloaded' - å½ DOMContentLoaded äºä»¶è¢«è§¦åæ¶ï¼è®¤ä¸ºæä½å®æã338 'load' - å½å è½½äºä»¶è¢«è§¦åæ¶ï¼è®¤ä¸ºæä½å·²ç»å®æã339 'networkidle' - å½è³å° 500 毫ç§æ²¡æç½ç»è¿æ¥æ¶ï¼è®¤ä¸ºæä½å®æã340 """341 if type(self._obj).__name__ == "Page":342 return self._obj.go_back(343 timeout=timeout,344 wait_until=wait_until,345 )346 elif type(self._obj).__name__ == "Frame":347 return self._obj.page.go_back(348 timeout=timeout,349 wait_until=wait_until,350 )351 else:352 raise TypeError(f"{self._obj}çç±»ååºå½æ¯ Page ç±»åæ Frame ç±»åã")353 def go_forward(354 self,355 timeout: float = None,356 wait_until: Literal["domcontentloaded", "load", "networkidle"] = None357 ):358 """导èªå°åå²è®°å½çä¸ä¸é¡µã359 è¿å主è¦èµæºååºã360 å¨å¤æ¬¡éå®åçæ
åµä¸ï¼å¯¼èªå°ä½¿ç¨ä¸æ¬¡éå®åçååºè¿è¡è§£æã361 å¦æä¸è½è¿åï¼åè¿å nullã362 :param timeout:æ大æä½æ¶é´ä»¥æ¯«ç§ä¸ºåä½ï¼é»è®¤ä¸º 30 ç§ï¼ä¼ é 0 以ç¦ç¨è¶
æ¶ã363 å¯ä»¥ä½¿ç¨ browser_context.set_default_navigation_timeout(timeout)ã364 browser_context.set_default_timeout(timeout)ã365 page.set_default_navigation_timeout(timeout)366 æ page.set_default_timeout(timeout) æ¹æ³æ´æ¹é»è®¤å¼ã367 :param wait_until: <"load"|"domcontentloaded"|"networkidle"> å½è®¤ä¸ºæä½æåæ¶ï¼é»è®¤å è½½ã äºä»¶å¯ä»¥æ¯ï¼#368 'domcontentloaded' - å½ DOMContentLoaded äºä»¶è¢«è§¦åæ¶ï¼è®¤ä¸ºæä½å®æã369 'load' - å½å è½½äºä»¶è¢«è§¦åæ¶ï¼è®¤ä¸ºæä½å·²ç»å®æã370 'networkidle' - å½è³å° 500 毫ç§æ²¡æç½ç»è¿æ¥æ¶ï¼è®¤ä¸ºæä½å®æã371 """372 if type(self._obj).__name__ == "Page":373 return self._obj.go_forward(374 timeout=timeout,375 wait_until=wait_until,376 )377 elif type(self._obj).__name__ == "Frame":378 return self._obj.page.go_forward(379 timeout=timeout,380 wait_until=wait_until,381 )382 else:383 raise TypeError(f"{self._obj}çç±»ååºå½æ¯ Page ç±»åæ Frame ç±»åã")384 def goto(385 self,386 url: str,387 *,388 timeout: float = None,389 wait_until: Literal["domcontentloaded", "load", "networkidle"] = None,390 referer: str = None391 ):392 """导èªå° `url`393 è¿å主è¦èµæºååºã å¨å¤æ¬¡éå®åçæ
åµä¸ï¼å¯¼èªå°ä½¿ç¨ä¸æ¬¡éå®åçååºè¿è¡è§£æã394 å¦æåºç°ä»¥ä¸æ
åµï¼è¯¥æ¹æ³å°æåºé误ï¼395 åå¨ SSL é误ï¼ä¾å¦ï¼å¨èªç¾åè¯ä¹¦çæ
åµä¸ï¼ã396 ç®æ ç½åæ æã397 导èªæé´è¶
æ¶ã398 è¿ç¨æå¡å¨æ²¡æååºææ æ³è®¿é®ã399 主èµæºå 载失败ã400 å½è¿ç¨æå¡å¨è¿åä»»ä½ææç HTTP ç¶æ代ç æ¶ï¼è¯¥æ¹æ³ä¸ä¼æåºé误ï¼å
æ¬ 404âæªæ¾å°âå 500âå
é¨æå¡å¨é误âã401 å¯ä»¥éè¿è°ç¨ response.status æ¥æ£ç´¢æ¤ç±»ååºçç¶æ代ç ã402 注æ:403 该æ¹æ³è¦ä¹æåºé误ï¼è¦ä¹è¿å主èµæºååºã å¯ä¸çä¾å¤æ¯å¯¼èªå° about:blank æ导èªå°å
·æä¸åæ£åçç¸å URLï¼è¿å°æå并è¿å nullã404 :param url:页é¢å¯¼èªå°ç URLã ç½ååºå
æ¬æ¹æ¡ï¼ä¾å¦ https://ã405 å½éè¿ä¸ä¸æé项æä¾ base_url 并ä¸ä¼ éç URL æ¯è·¯å¾æ¶ï¼å®ä¼éè¿æ°ç URL() æé å½æ°å并ã406 :param timeout: æ大æä½æ¶é´ä»¥æ¯«ç§ä¸ºåä½ï¼é»è®¤ä¸º 30 ç§ï¼ä¼ é 0 以ç¦ç¨è¶
æ¶ã407 å¯ä»¥ä½¿ç¨ browser_context.set_default_navigation_timeout(timeout)ã408 browser_context.set_default_timeout(timeout)ã409 page.set_default_navigation_timeout(timeout)410 æ page.set_default_timeout(timeout) æ¹æ³æ´æ¹é»è®¤å¼ã411 :param wait_until: <"load"|"domcontentloaded"|"networkidle"> å½è®¤ä¸ºæä½æåæ¶ï¼é»è®¤å è½½ã äºä»¶å¯ä»¥æ¯ï¼#412 'domcontentloaded' - å½ DOMContentLoaded äºä»¶è¢«è§¦åæ¶ï¼è®¤ä¸ºæä½å®æã413 'load' - å½å è½½äºä»¶è¢«è§¦åæ¶ï¼è®¤ä¸ºæä½å·²ç»å®æã414 'networkidle' - å½è³å° 500 毫ç§æ²¡æç½ç»è¿æ¥æ¶ï¼è®¤ä¸ºæä½å®æã415 :param referer: å¼ç¨æ 头å¼ã å¦ææä¾ï¼å®å°ä¼å
äº page.set_extra_http_headers(headers) 设置çå¼ç¨æ 头å¼.416 """417 return self._obj.goto(418 url=url,419 timeout=timeout,420 wait_until=wait_until,421 referer=referer,422 )423 def hover(424 self,425 selector: str,426 timeout: float = None,427 modifiers: Optional[428 List[Literal["Alt", "Control", "Meta", "Shift"]]429 ] = None,430 position: Position = None,431 ):432 """é¼ æ æ¬å433 æ¤æ¹æ³éè¿æ§è¡ä»¥ä¸æ¥éª¤å°é¼ æ æ¬åå¨å
ç´ ä¸ï¼434 çå¾
对å
ç´ çå¯æä½æ§æ£æ¥ã435 å¦æéè¦ï¼å°å
ç´ æ»å¨å°è§å¾ä¸ã436 ä½¿ç¨ page.mouse å°é¼ æ æ¬åå¨å
ç´ çä¸å¿ææå®ä½ç½®ä¸ã437 çå¾
å¯å¨ç导èªæåæ失败438 :param position: ç¸å¯¹äºå
ç´ å¡«å
æ¡çå·¦ä¸è§ä½¿ç¨çç¹ã å¦ææªæå®ï¼å使ç¨å
ç´ çä¸äºå¯è§ç¹ã439 :param modifiers: è¦æä¸ç修饰é®ã ç¡®ä¿å¨æä½æé´ä»
æä¸è¿äºä¿®é¥°ç¬¦ï¼ç¶åå°å½å修饰符æ¢å¤åæ¥ã å¦ææªæå®ï¼å使ç¨å½åæä¸ç修饰符440 :param selector: ç¨äºæç´¢å
ç´ çéæ©å¨ã å¦ææå¤ä¸ªå
ç´ æ»¡è¶³éæ©å¨ï¼å°ä½¿ç¨ç¬¬ä¸ä¸ªã441 :param timeout: æ大æä½æ¶é´ä»¥æ¯«ç§ä¸ºåä½ï¼é»è®¤ä¸º 30 ç§ï¼ä¼ é 0 以ç¦ç¨è¶
æ¶ã442 å¯ä»¥ä½¿ç¨ browser_context.set_default_navigation_timeout(timeout)ã443 browser_context.set_default_timeout(timeout)ã444 page.set_default_navigation_timeout(timeout)445 æ page.set_default_timeout(timeout) æ¹æ³æ´æ¹é»è®¤å¼ã446 """447 element = self._find_element_cross_frame(selector=selector)448 element.hover(449 modifiers=modifiers,450 timeout=timeout,451 position=position,452 )453 def inner_html(self, selector: str) -> str:454 """å
ç´ ç innerHTML å¼ã455 :param selector: ç¨äºæç´¢å
ç´ çéæ©å¨ã å¦ææå¤ä¸ªå
ç´ æ»¡è¶³éæ©å¨ï¼å°ä½¿ç¨ç¬¬ä¸ä¸ªã456 """457 element = self._find_element_cross_frame(selector)458 return element.inner_html()459 def inner_text(self, selector: str) -> str:460 """å
ç´ ç innerText å¼ã461 :param selector: ç¨äºæç´¢å
ç´ çéæ©å¨ã å¦ææå¤ä¸ªå
ç´ æ»¡è¶³éæ©å¨ï¼å°ä½¿ç¨ç¬¬ä¸ä¸ªã462 """463 element = self._find_element_cross_frame(selector)464 return element.inner_text()465 def input_value(self, selector: str, timeout: float = None) -> str:466 """å
ç´ ç value å±æ§çå¼ã467 :param selector: ç¨äºæç´¢å
ç´ çéæ©å¨ã å¦ææå¤ä¸ªå
ç´ æ»¡è¶³éæ©å¨ï¼å°ä½¿ç¨ç¬¬ä¸ä¸ªã468 :param timeout: æ大æä½æ¶é´ä»¥æ¯«ç§ä¸ºåä½ï¼é»è®¤ä¸º 30 ç§ï¼ä¼ é 0 以ç¦ç¨è¶
æ¶ã469 å¯ä»¥ä½¿ç¨ browser_context.set_default_navigation_timeout(timeout)ã470 browser_context.set_default_timeout(timeout)ã471 page.set_default_navigation_timeout(timeout)472 æ page.set_default_timeout(timeout) æ¹æ³æ´æ¹é»è®¤å¼473 """474 element = self._find_element_cross_frame(selector)475 return element.input_value(timeout=timeout)476 def is_checked(self, selector: str) -> bool:477 """è¿åæ¯å¦éä¸å
ç´ ãå¦æå
ç´ ä¸æ¯å¤éæ¡æåéè¾å
¥ï¼åå¼åå¼å¸¸ã"""478 return self._find_element_cross_frame(selector).is_checked()479 def is_disabled(self, selector: str) -> bool:480 """è¿åå
ç´ æ¯å¦è¢«ç¦ç¨ï¼ä¸å¯ç¨ç¸åã"""481 return self._find_element_cross_frame(selector).is_disabled()482 def is_editable(self, selector: str) -> bool:483 """è¿åå
ç´ æ¯å¦å¯ç¼è¾ã"""484 return self._find_element_cross_frame(selector).is_editable()485 def is_enabled(self, selector: str) -> bool:...
post.py
Source: post.py
...11logger = Logger()12# async def ig_context(page, postId):13async def ig_context(page, postId, playwright):14 '''åå¾ææ¡'''15 page.set_default_navigation_timeout(60000)16 a_list = []17 a_info = []18 all_a_text = '//html/body/div[1]/section/main/div/div[1]/article/div[3]/div[1]/ul/div/li/div/div/div[2]/span/a'19 context1_xpath = '//html/body/div[1]/section/main/div/div[1]/article/div[3]/div[1]/ul/div/li/div/div/div[2]/span'20 context2_xpath = '//html/body/div[1]/section/main/div/div/article/div[3]/div[1]/ul/div/li/div/div/div[2]/span'21 exist_context = ''22 for i in range(5):23 try:24 await page.goto(f"https://www.instagram.com/p/{postId}/")25 await page.wait_for_load_state('load')26 await page.wait_for_load_state('domcontentloaded')27 await page.wait_for_load_state('networkidle')28 await page.wait_for_timeout(random.randint(3000,5000))29 print('IG å·²é²å
¥ç²å°')30 exists = await page.is_visible(context1_xpath)31 print(exists)32 break33 except TimeoutError as e:34 await page.screenshot(path='IG_TimeoutError1.png')35 print(f'IG: {postId} é£ç·é¾æ(æªé²å
¥ç²å°) å試第{i}次')36 logger.error(f'IG: {postId} é£ç·é¾æ(æªé²å
¥ç²å°) å試第{i}次')37 continue38 try:39 print('解æä¸')40 await page.screenshot(path='IG_debug.png')41 for context in [context1_xpath, context2_xpath]:42 try:43 await page.wait_for_selector(context, timeout=6000)44 except TimeoutError:45 print('pass')46 exists = await page.is_visible(context)47 if exists:48 exist_context += context49 print(f'xpath found')50 break51 else:52 print(f'pass {context}')53 54 # if not context_exist:55 # print('Context not found')56 # await page.screenshot(path='IG_context_notfound.png')57 # return None, None58 print('1')59 all_a_text = await page.query_selector_all(all_a_text)60 print('2')61 print(exist_context)62 text = await page.inner_text(exist_context,timeout=0)63 print('Text get')64 for a in all_a_text:65 a_text = await a.inner_text()66 print(f'Link get: {a_text}')67 attrs = await a.get_attribute('class')68 print(attrs)69 href = await a.get_attribute('href')70 print(href)71 if attrs == 'notranslate':72 print('Found tag')73 url = f'https://www.instagram.com{href}'74 print(url)75 tag_name = await _get_tag_name(url)76 tag_info = {'tag': a, 'name':tag_name}77 a_info.append(tag_info)78 # # print('Tag name saved')79 80 a_list.append(a)81 logger.info(f'IG: {postId} IG å·²åå¾ææ¡ https://www.instagram.com/p/{postId}/')82 return text, a_list83 except TimeoutError:84 await page.screenshot(path='IG_TimeoutError2.png')85 logger.error(f'IG ææ¡æ¾ä¸å°æ¨ç±¤ è«ç¢ºèª IG æ¯å¦æ¹ç')86 87 except Exception as e:88 await page.screenshot(path='IG_UnexpectedError.png')89 logger.error(f'IG ææ¡: é æå¤é¯èª¤ {e}')90 print(f'IG ææ¡: é æå¤é¯èª¤ {e}')91 # try:92 # likes = await page.inner_text('//html/body/div[1]/section/main/div/div[1]/article/div[3]/section[2]/div/div[2]/a/span')93 # likes = int(likes)94 # except TimeoutError:95 # likes = 096 # logger.error(f'IG ææ¡è®æ¸æ¾ä¸å°æ¨ç±¤ è«ç¢ºèª IG æ¯å¦æ¹ç')97 98 99 # loop = asyncio.get_event_loop()100 # context, a_list = loop.run_until_complete(get_post_context(page, postId))101 # print('IG å·²æ·åææ¡ï¼')102 # print('='*30)103 # print(context)104 # print('='*30)105 # return context, a_list106async def _get_tag_name(url):107 playwright = await async_playwright().start() 108 browser = await playwright.firefox.launch(headless=True, proxy={'server':'proxy.soax.com:9010','username':'F3JZJYifgvqVCHbd','password':'wifi;gb;three;;'}) # IGåªè½ç¨firefox (chromiumæ被æçµè¨ªå)109 # browser = await playwright.firefox.launch(headless=True, proxy={'server':'34.81.17.230:8080'}) # IGåªè½ç¨firefox (chromiumæ被æçµè¨ªå)110 my_browser = await browser.new_context(user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36')111 page = await my_browser.new_page()112 try:113 await page.goto(url)114 await page.screenshot(path='IG_debug1.png')115 tag_name = await page.inner_text('//html/body/div[1]/section/main/div/div[1]/h1')116 return tag_name117 except TimeoutError as e:118 print(e)119 await page.screenshot(path='IG_1TimeoutError.png')120async def extract_comments_full(page, postData):121 122 output_json = []123 postId = postData['postId']124 async def _get_post_comment(page, postId, output_json):125 page.set_default_navigation_timeout(70000)126 # é²å
¥ç²å°é é¢127 for i in range(5):128 try:129 await page.goto(f"https://www.instagram.com/p/{postId}/")130 await page.wait_for_load_state('load')131 await page.wait_for_timeout(random.randint(4000,8000))132 break133 except TimeoutError as e:134 await page.screenshot(path='IG_kol_page_timeout.png')135 print(f'IG é£ç·é¾æ: éæ°å試第{i}次')136 logger.error(f'IG é£ç·é¾æ: éæ°å試第{i}次 {e}')137 sleep(3)138 # raise f'é£ç·é¾æ: {e}'139 continue140 # æ·åçè¨ååçè¨141 return Comment(output_json, page)142 loop = asyncio.get_event_loop() 143 loop.run_until_complete(_get_post_comment(page, postId, output_json))144 145 postData['comments'] = output_json146 147 return postData148async def basic_count(page, postId):149 async def get_basic_count(page, postId):150 for i in range(5):151 try:152 await page.goto(f"https://www.instagram.com/p/{postId}/")153 await page.wait_for_load_state('load')154 await page.wait_for_timeout(random.randint(4000,8000))155 break156 except TimeoutError as e:157 await page.screenshot(path='IG_kol_page_timeout.png')158 print(f'IG é£ç·é¾æ: éæ°å試第{i}次')159 logger.error(f'IG é£ç·é¾æ: éæ°å試第{i}次 {e}')160 sleep(3)161 # raise f'é£ç·é¾æ: {e}'162 163 likes = await page.inner_text('//html/body/div[1]/section/main/div/div[1]/article/div[3]/section[2]/div/div/a/span')164 likes = int(likes)165 await press_more_comments(page)166 comments = await page.query_selector_all('//html/body/div[1]/section/main/div/div[1]/article/div[3]/div[1]/ul/ul')167 comment_count = 0168 if not comments == []:169 for c in comments:170 comment_count += 1171 more_replies_button = await c.query_selector('//li/ul/li/div/button/span')172 if more_replies_button:173 button_text = await more_replies_button.inner_text()174 replies_count = re.search(r'(\d+)', button_text).group(1)175 comment_count += int(replies_count) 176 177 print(f'IG Comment_count:{comment_count} Likes:{likes}')178 return (likes, comment_count)179 180 loop = asyncio.get_event_loop()181 likes, comment_count = loop.run_until_complete(get_basic_count(page, postId))182 return (likes, comment_count)183async def get_post_context(page, postId):184 '''åå¾ææ¡'''185 page.set_default_navigation_timeout(30000)186 for i in range(5):187 try:188 await page.goto(f"https://www.instagram.com/p/{postId}/")189 await page.wait_for_load_state('load')190 # await page.wait_for_load_state('domcontentloaded')191 # await page.wait_for_load_state('networkidle')192 print('IG å·²é²å
¥ç²å°')193 break194 except TimeoutError as e:195 await page.screenshot(path='IG_TimeoutError1.png')196 print(f'IG: {postId} é£ç·é¾æ(æªé²å
¥ç²å°) å試第{i}次')197 logger.error(f'IG: {postId} é£ç·é¾æ(æªé²å
¥ç²å°) å試第{i}次')198 sleep(3)199 continue...
ggogle_tans.py
Source: ggogle_tans.py
...14 context.set_default_timeout(0)15 # Open new page16 page1 = context.new_page()17 page1.set_default_timeout(0)18 page1.set_default_navigation_timeout(0)19 page2 = context.new_page()20 page2.set_default_timeout(0)21 page2.set_default_navigation_timeout(0)22 # Go to https://translate.google.cn/?sl=en&tl=zh-CN&op=translate23 page1.goto("https://translate.google.cn/?sl=en&tl=zh-CN&op=translate")24 page2.goto("https://translate.google.cn/?sl=en&tl=zh-CN&op=translate")25 # Click [aria-label="åæ"]26 # page.click("[aria-label=\"åæ\"]")27 # Fill [aria-label="åæ"]28 # ä¸ä¸ªç®åç并è¡ï¼æéè¦ç¿»è¯çå
容åæ两é¨åï¼åå¼å¨ä¸¤ä¸ªç½é¡µä¸ç¿»è¯29 result1 = []30 result2 = []31 trans_num = len(trans_list)32 trans_lis_1 = trans_list[0:trans_num // 2]33 trans_lis_2 = trans_list[trans_num // 2:trans_num]34 for i,j in zip(trans_lis_1, trans_lis_2):35 # æå
容åå«è¾å
¥å°ä¸¤ä¸ªç½é¡µä¸è¿è¡ç¿»è¯ï¼ç¶åä¼æ¯3s...
app.py
Source: app.py
...10mydb = Database(f'mongodb://{os.environ["MONGODB_USERNAME"]}:{os.environ["MONGODB_PASSWORD"]}@{os.environ["MONGODB_HOSTNAME"]}:27017/')11async def worker(context, url: str):12 page = await context.new_page()13 page.set_default_timeout(180000)14 page.set_default_navigation_timeout(180000)15 await page.goto(url, timeout=0)16 await page.locator('//*[@id="__next"]/div[1]/div[3]/div[3]/div[2]/div[2]/div[2]/div[1]/div/h1').wait_for()17 product_star = page.locator('//div[@class="d-none d-block-lg ml-12 left-0 pos-sticky"]/div[@class="d-flex ai-center"]/p[1]')18 product_qualities = await page.query_selector_all('//div[@class="d-flex ai-center bg-color-neutral-600 mr-auto"]/p[@class="text-body-2"]')19 quality_construction = await product_qualities[0].text_content()20 purchase_value = await product_qualities[1].text_content()21 innovation = await product_qualities[2].text_content()22 features = await product_qualities[3].text_content()23 ease_of_use = await product_qualities[4].text_content()24 design = await product_qualities[5].text_content()25 product_star = await product_star.all_text_contents()26 product_star = product_star[0]27 query = dict(time=datetime.datetime.now(), link=url, quality_construction=quality_construction, purchase_value=purchase_value, innovation=innovation,28 features=features, ease_of_use=ease_of_use, design=design, product_star=product_star)29 # save post details30 mydb.insert_query(query=query, db_name='digikala', col_name='product_detail')31async def main():32 async with async_playwright() as playwright:33 browser = await playwright.chromium.launch(headless=True)34 host = "https://www.digikala.com"35 product_pre = "https://www.digikala.com/product"36 context = await browser.new_context()37 # Open new page38 page = await context.new_page()39 # set 90 seconds timeout for poor connections40 page.set_default_timeout(90000)41 page.set_default_navigation_timeout(90000)42 # Go to https://www.digikala.com/search/category-mobile-phone/43 await page.goto("https://www.digikala.com/search/category-mobile-phone/", timeout=90000)44 await page.locator(45 "//html/body/div[1]/div[1]/div[3]/div[3]/div[1]/div/section[1]/div[2]/div[1]/div/div[1]/article").wait_for()46 result = html.fromstring(await page.content())47 products = result.xpath("//article/a")48 product_links = []49 for product in products:50 image = product.xpath(".//img[not(contains(@data-src, '.svg'))][1]")51 if image:52 image = image[0].get("data-src")53 try:54 title = product.xpath(".//h2//text()")[0]55 link = product.get("href")...
Playwright error connection refused in docker
playwright-python advanced setup
How to select an input according to a parent sibling label
Error when installing Microsoft Playwright
Trouble waiting for changes to complete that are triggered by Python Playwright `select_option`
Capturing and Storing Request Data Using Playwright for Python
Can Playwright be used to launch a browser instance
Trouble in Clicking on Log in Google Button of Pop Up Menu Playwright Python
Scrapy Playwright get date by clicking button
React locator example
I solved my problem. In fact my docker container (frontend) is called "app" which is also domain name of fronend application. My application is running locally on http. Chromium and geko drivers force httpS connection for some domain names one of which is "app". So i have to change name for my docker container wich contains frontend application.
Check out the latest blogs from LambdaTest on this topic:
The sky’s the limit (and even beyond that) when you want to run test automation. Technology has developed so much that you can reduce time and stay more productive than you used to 10 years ago. You needn’t put up with the limitations brought to you by Selenium if that’s your go-to automation testing tool. Instead, you can pick from various test automation frameworks and tools to write effective test cases and run them successfully.
When it comes to web automation testing, there are a number of frameworks like Selenium, Cypress, PlayWright, Puppeteer, etc., that make it to the ‘preferred list’ of frameworks. The choice of test automation framework depends on a range of parameters like type, complexity, scale, along with the framework expertise available within the team. However, it’s no surprise that Selenium is still the most preferred framework among developers and QAs.
Playwright is a framework that I’ve always heard great things about but never had a chance to pick up until earlier this year. And since then, it’s become one of my favorite test automation frameworks to use when building a new automation project. It’s easy to set up, feature-packed, and one of the fastest, most reliable frameworks I’ve worked with.
The speed at which tests are executed and the “dearth of smartness” in testing are the two major problems developers and testers encounter.
With the rapidly evolving technology due to its ever-increasing demand in today’s world, Digital Security has become a major concern for the Software Industry. There are various ways through which Digital Security can be achieved, Captcha being one of them.Captcha is easy for humans to solve but hard for “bots” and other malicious software to figure out. However, Captcha has always been tricky for the testers to automate, as many of them don’t know how to handle captcha in Selenium or using any other test automation framework.
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!