- Automation Advisor
- playwright-python
- all_inner_texts
Best Python code snippet using playwright-python
pw_getHisDataJ_test3.py
Source:pw_getHisDataJ_test3.py
...49 # 그리ê³, 첫ë²ì§¸í¸ë¦¬êµ¬ì¡°ìì g ì ì½ì¸ì´ë¦ì´ ë¤ì´ìê³ ëë²ì§¸í¸ë¦¬êµ¬ì¡°ìì i ì ì½ì¸ì´ë¦ì´ ë¤ì´ìë¤ê³ íë©´, '~~ X Y Z' ííì ì
ëí°ë¡ Zë ë 구조ì Z 모ë ì°¾ìì§ì§ë§, (ì¬ê¸°ì ë´ê° '구조'ë¼ê³ íëê±´ ìì²´ í¸ë¦¬ì ì¼ë¶ë¥¼ ì기íëê²ì.) 50 # ì½ì¸ì´ë¦ì ê°ì¸ì¤ê¸°ìí´ ì´ ì
ëí°ì ë¤ì ' f g' 를 ë¶ì¬ì '~~ X Y Z f g' ì
ëí°ë¥¼ ì°ë©´ í¸ë¦¬ê²½ë¡1ì 매ì¹ëë ì½ì¸ì´ë¦(ìê°ì§ì리먼í¸)ë¤ë§ ì°¾ìì§ëê±°ì§. 51 # '~~ X Y Z i' ì
ëí°ë¥¼ ì°ë©´ í¸ë¦¬ê²½ë¡2ì ì½ì¸ì´ë¦(ìê°ì§ì리먼í¸)ë¤ë§ ì°¾ìì§ëê±°ê³. 52 # ë°ë¼ì, ë§ì°ì¤íì¤í¬ë¡¤ ìëë¡ ë´ë¦¬ì§ ììë, ê·¸ë¥ ëê°ì§ ì
ëí°ë¥¼ ì¬ì©íë©´ ííì´ì§ì 100ê° ì½ì¸ì´ë¦ë¤ì ìë¶ ë¤ ê°ì¸ì¬ ì ìëê±°ì§. 53 coinCMCnames_inViewport = await page.locator('tr td a[href*="/currencies/"][href$="/"]:not([href$="/markets/"]):not([href$="/airdrop/"]) >div>div>p').all_inner_texts() 54 coinCMCtickers_inViewport = await page.locator('tr td a[href*="/currencies/"][href$="/"]:not([href$="/markets/"]):not([href$="/airdrop/"]) >div>div>div>p').all_inner_texts() 55 coinCMCnames_outViewport = await page.locator('tr td a[href*="/currencies/"][href$="/"]:not([href$="/markets/"]):not([href$="/airdrop/"]) > :nth-child(2)').all_inner_texts()56 coinCMCtickers_outViewport = await page.locator('tr td a[href*="/currencies/"][href$="/"]:not([href$="/markets/"]):not([href$="/airdrop/"]) > :nth-child(3)').all_inner_texts()57 coinCMCnames_oneP = coinCMCnames_inViewport + coinCMCnames_outViewport 58 coinCMCtickers_oneP = coinCMCtickers_inViewport + coinCMCtickers_outViewport 59 assert len(coinCMCnames_oneP)==len(set(coinCMCnames_oneP))==len(coinCMCtickers_oneP)==len(set(coinCMCtickers_oneP)) == 100 60 coinCMCnameTickerTups_oneP = list(zip(coinCMCnames_oneP, coinCMCtickers_oneP)) 61 nameTickerTup2coinUrl_oneP = {nameTickerTup: coinUrl for (nameTickerTup, coinUrl) in zip(coinCMCnameTickerTups_oneP, urls_oneP)} 62 # print(f'j) ì½ì¸CMC(ì´ë¦,í°ì»¤)ë¤ {len(coinCMCnameTickerTups_oneP)}ê°: {coinCMCnameTickerTups_oneP}\n') 63 print(f'j) {pageUrl}ì ì½ì¸CMC(ì´ë¦,í°ì»¤)->ì½ì¸url 맵 (ì½ì¸ {len(nameTickerTup2coinUrl_oneP)}ê°): {nameTickerTup2coinUrl_oneP}\n') 64 65 66 # await page.mouse.wheel(0, 9000) 67 # # await page.wait_for_timeout(2500) 68 # coinCMCnames_loc = page.locator('tr td a[href*="/currencies/"][href$="/"]:not([href$="/markets/"]):not([href$="/airdrop/"])') # ì¼ë¨ ì¤í¬ë¡¤ 맨ë°ê¹ì§ ë´ë¦¬ê³ ì´ê±° ì°ë©´ ì½ì¸CMCì´ë¦ì´ í¬í¨ë¼ì ëì¤ê¸´ íë¤!!! /21.12.14.2:28. 69 # # coinCMCnames_loc = page.locator('tr td a[href*="/currencies/"][href$="/"]:not([href$="/markets/"])>div>div>p') 70 # # coinCMCnames_loc = page.locator('tbody>tr>td>div>a>div>div>p') 71 # print(f'j) coinCMCnames_loc.count(): {await coinCMCnames_loc.count()}') 72 # all_inner_texts = await coinCMCnames_loc.all_inner_texts()73 # print(f'\nj) {pageUrl}ì all_inner_texts {len(all_inner_texts)}ê°: {all_inner_texts}')74 # all_text_contents = await coinCMCnames_loc.all_text_contents() 75 # print(f'\nj) {pageUrl}ì all_text_contents {len(all_text_contents)}ê°: {all_text_contents}') 76 77 # coinCMCnames_oneP = await coinCMCnames_loc.evaluate_all('selecteds=>selecteds.map(e=>e.innerText)') 78 # # print(f'j) {pageUrl} ì ì½ì¸CMCì´ë¦ë¤ {len(coinCMCnames_oneP)}ê°: {coinCMCnames_oneP}\n') 79 return urls_oneP, coinCMCnames_oneP 80 # TODO TODO TODO ë©ì¸íë©´ì ì½ì¸ëª
, urlì ì½ì¸ëª
ëë¤ ê°ì¸ìì 맵íí´ëëê² ì¢ìë¯. /21.12.12.13:48. 81 82 # TODO TODO TODO 맨ë§ì§ë§ ë± íê° ì½ì¸ {'https://coinmarketcap.com/currencies/apenft/'} ë문ì ê³~~~ì while문 ëë¤;;; ëì§?? 83 # í¹ì ë§ì°ì¤ë¡ ë¤ìíì´ì§ í´ë¦íëê±°ë ë¬ë¦¬, urlë¡ ë°ë¡ ë¤ìíì´ì§ë¡ ëì´ê°ë©´ ë ë¤ë¥¸ê°??? /21.12.12.23:24. 84 # ì¡°ì¬ëì ì½ì¸ë¤ url ê°ì¸ì´. 85 while True: # í¹ìë ííì´ì§(100ê°ì½ì¸)ë¨ìë¡ ê°ì¸ì¤ëëì¤ ìì´ìì ë¬ë¼ì¸ì ì¤ë³µëëì½ì¸ ì길경ì°, 첫íì´ì§ë¶í° ë¤ì ìì. /21.12.12.16:26. 86 coinUrls = []...
pw_getHisDataJ_test.py
Source:pw_getHisDataJ_test.py
...32 # ì´ì í¹ì ì½ì¸ì nì¼ì¹ ìì¸ë°ì´í°ê° 모ë ì¹íì´ì§ì ë³´ì´ë ìí©ì. ì§ê¸ì 1ë
ì¹ë¡ í´ì¤¬ê³. 33 tableRows_loc = page.locator('table.cmc-table tbody tr') 34 # print(f'j) type tableRows_loc: {type(tableRows_loc)}') # <class 'playwright.async_api._generated.Locator'> 35 print(f'j) tableRows_loc.count(): {await tableRows_loc.count()}') 36 # print(f'j) tableRows_loc.all_inner_texts(): {await tableRows_loc.all_inner_texts()}') 37 38 # ê± ëª¨ë tdë¤ì ìíí locatorë¡ all_inner_texts í´ì£¼ê³ëì ê° row ë³ë¡ 묶ì´ì¤ë ëì§ë§, í¹ìë ììê° ìëë¡ ìëê±°ë íê¹ë´ ì´ëê² rowë³ë¡ í´ì¤ë´. /21.12.2.13:08. 39 table_vals = await tableRows_loc.evaluate_all(40 """41 trs=>trs.map(42 tr => Array.from(tr.childNodes).map(td=>td.innerText) 43 ) 44 """45 )46 print(f'j) len table_vals: {len(table_vals)}') 47 print(f'j) table_vals: {table_vals}') 48 # # ê·¸ë¥ íë² í´ë³¸ ë¶ë¶. 49 # # 모ë tdë¤ ìíí´ì rowë³ë¡ 묶ìë¤ì ìê°ì´ë ëê°ìì§ ë¹êµí´ë´. /21.12.2.13:12. 50 # tableCells_loc = page.locator('table.cmc-table tbody tr td') # 모ë td ë¤. ì¢->ì°, ì->í ììëë¡ì¸ë¯? /21.12.2.12:43. 51 # print(f'j) tableCells_loc.count(): {await tableCells_loc.count()}') 52 # tableCells = await tableCells_loc.all_inner_texts() 53 # table_vals2 = []54 # row = []55 # for i, e in enumerate(tableCells):56 # row.append(e) 57 # if (i+1)%7 == 0: 58 # table_vals2.append(row) 59 # row = [] 60 # print(f'\nj) len table_vals2: {len(table_vals2)}') 61 # print(f'j) table_vals2: {table_vals2}') 62 # # table_vals ë table_vals2 ë ê°ë¤ ë° ìì ììí ëê°ìì§ í¨ íì¸í´ë´. /21.12.2.13:28. 63 # for (row1, row2) in zip(table_vals, table_vals2): 64 # for (e1, e2) in zip(row1, row2):65 # if e1!=e2:66 # raise ValueError(f'j) Error!!! ê°ì´ ì¼ì¹í´ì¼íëë° ë¤ë¦!!! {e1} != {e2}') ...
subito.py
Source:subito.py
...35 for t in typology:36 house_links[m] = {swap_dict(typology_map['subito'])[t]: []}37 try:38 page.goto(f"https://www.subito.it/annunci-sicilia/vendita/{t}/catania/{m}")39 navs_txt = ' '.join(page.locator("nav").all_inner_texts())40 max_page = max([int(n) for n in re.findall(r"(\d+)", navs_txt)])41 except:42 max_page = 143 for page_n in range(1, max_page+1):44 page.goto(f"https://www.subito.it/annunci-sicilia/vendita/{t}/catania/{m}/?o={page_n}",45 wait_until='domcontentloaded', timeout=30*1000)46 houses_html = page.locator('.items').first.inner_html()47 soup = BeautifulSoup(houses_html, 'html.parser')48 house_links[m][swap_dict(typology_map['subito'])[t]].extend([l['href'] for l in soup.find_all('a', href=True)49 if urlparse(l['href']).path.startswith('/'+t)])50 print(house_links.keys())51 page.close()52 context.close()53 houses = []54 for m in house_links.keys():55 for t in house_links[m].keys():56 hl_stacks = np.array_split(house_links[m][t], ceil(len(house_links[m][t])/250))57 for hl_stack in hl_stacks:58 context = open_context(browser, trace)59 for link in tqdm(hl_stack, total=len(hl_stack)):60 page = context.new_page()61 page.route(re.compile(r"(\.png$)|(\.jpg$)"), lambda route: route.abort())62 page.goto(link, wait_until='domcontentloaded')63 title = page.locator('h1').first.inner_text()64 surface = page.locator("text=/\d+ mq/").first.inner_text()65 description = page.locator('p:below(:text("Descrizione"))').first.inner_text()66 index = int(re.findall(r"(\d+)", page.url)[-1])67 house = House(index, 'subito', link, t, m, title, surface, description)68 69 if page.is_visible("span:has-text('â¬')"):70 price = page.locator("span:has-text('â¬')").first.inner_text()71 house.price = price72 else:73 house.price = ''74 if page.is_visible('span:right-of(:text("Piano"))'):75 ait = ' '.join(page.locator('span:right-of(:text("Piano"))').all_inner_texts())76 house.floor = re.findall(r"\d{1}", ait)[0]77 else:78 house.floor = ''79 80 if page.is_visible('span:right-of(:text("Locali"))'):81 ait = ' '.join(page.locator('span:right-of(:text("Locali"))').all_inner_texts())82 house.rooms = re.findall(r"\d{1,2}", ait)[0]83 else:84 house.rooms = ''85 houses.append(house)86 page.close()87 context.close()88 df = pd.DataFrame(houses)89 df.to_csv("house.csv", index=False)90 print(df)91 houses = SubitoHouses(df)92 houses.preprocess()93 houses.dump(pd.Timestamp.now().strftime("%Y-%m-%d"))...
pw_getHisDataJ_test4.py
Source:pw_getHisDataJ_test4.py
...24 print(f'j) {pageUrl} ì ê° ì½ì¸ urlë¤ ì´ {len(urls_oneP)}ê° ì°¾ì. (100ê°ì¬ì¼í¨)') 25 # assert (await coinUrls_loc.count()) == len(urls_oneP) == 100, f'j) {pageUrl} ì ê° ì½ì¸ urlì´ {len(urls_oneP)}ê°ì!!! (100ê°ì¬ì¼íëë°.)' 26 27 # # (ì½ì¸CMCì´ë¦, í°ì»¤) ííì 리ì¤í¸ ë§ë¦. ëì¤ì ì½ì¸CMCì´ë¦<->ì½ì¸urlì´ë¦ 맵í ìí´. /21.12.14.22:33. 28 # coinCMCnames_inViewport = await page.locator('tr td a[href*="/currencies/"][href$="/"]:not([href$="/markets/"]):not([href$="/airdrop/"]) >div>div>p').all_inner_texts() 29 # coinCMCtickers_inViewport = await page.locator('tr td a[href*="/currencies/"][href$="/"]:not([href$="/markets/"]):not([href$="/airdrop/"]) >div>div>div>p').all_inner_texts() 30 # coinCMCnames_outViewport = await page.locator('tr td a[href*="/currencies/"][href$="/"]:not([href$="/markets/"]):not([href$="/airdrop/"]) > :nth-child(2)').all_inner_texts()31 # coinCMCtickers_outViewport = await page.locator('tr td a[href*="/currencies/"][href$="/"]:not([href$="/markets/"]):not([href$="/airdrop/"]) > :nth-child(3)').all_inner_texts()32 # coinCMCnames_oneP = coinCMCnames_inViewport + coinCMCnames_outViewport # ëí´ì£¼ë ìì ì¤ì. /21.12.14.20:10. 33 # coinCMCtickers_oneP = coinCMCtickers_inViewport + coinCMCtickers_outViewport 34 # assert len(coinCMCnames_oneP)==len(set(coinCMCnames_oneP))==len(coinCMCtickers_oneP)==len(set(coinCMCtickers_oneP)) == 100 35 # coinCMCnameTickerTups_oneP = list(zip(coinCMCnames_oneP, coinCMCtickers_oneP)) # [('Bitcoin', 'BTC), ('Ethereum', 'ETH'), ...] 36 # # print(f'j) ì½ì¸CMC(ì´ë¦,í°ì»¤)ë¤ {len(coinCMCnameTickerTups_oneP)}ê°: {coinCMCnameTickerTups_oneP}\n') 37 38import time 39t1 = time.time()...
Playwright tutorial
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.
Chapters:
- What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
- How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
- Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
- What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
- Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
- Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
- Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
- Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
- Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
- Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
- Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
- Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.
Run Playwright Python automation tests on LambdaTest cloud grid
Perform automation testing on 3000+ real desktop and mobile devices online.
View sample repo View Documentation
Sign up Free › _Try LambdaTest Now !!
Get 100 minutes of automation test minutes FREE!!
Sign up with Email