There are several ways to compile Python code to an executable (.exe) file. Here are the most popular methods:
PyInstaller is the most widely used tool and works well for most projects:
# Install
pip install pyinstaller| const { chromium } = require('playwright'); | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| async function downloadAndCheckFile() { | |
| const downloadPath = path.join(__dirname, 'downloads'); | |
| // Create downloads directory if it doesn't exist | |
| if (!fs.existsSync(downloadPath)) { | |
| fs.mkdirSync(downloadPath, { recursive: true }); |
Mock API (API giả lập) là một phiên bản giả của API thực, được tạo ra để mô phỏng hành vi và phản hồi của API thật mà không cần kết nối đến server backend thực tế. Mock API trả về dữ liệu mẫu đã được định nghĩa trước thay vì dữ liệu thực từ database hay các service khác.
Giả sử bạn đang phát triển một ứng dụng quản lý sản phẩm:
API thực:
Trả lời: Selenium WebDriver là một công cụ automation testing mã nguồn mở, cho phép tương tác trực tiếp với trình duyệt web thông qua các API native của browser. WebDriver hỗ trợ nhiều ngôn ngữ lập trình như Java, Python, C#, Ruby và JavaScript.
Ví dụ code Java:
| import { test, expect, Page } from '@playwright/test'; | |
| import { faker } from '@faker-js/faker'; | |
| import path from 'path'; | |
| test.describe('Lesson 02 - Ex 01', async () => { | |
| const baseUrl = 'https://material.playwrightvn.com/'; | |
| const registerData = { | |
| username: faker.person.fullName(), | |
| email: faker.internet.email(), |
| import { test } from '@playwright/test'; | |
| test("Register", async ({ page }) => { | |
| await page.goto('https://material.playwrightvn.com/'); | |
| await page.click('//a[@href="01-xpath-register-page.html"]'); | |
| await page.locator('//input[@id="username"]').fill('Trangdt98'); | |
| await page.locator('//input[@id="email"]').fill('doantranghn98@gmail.com'); | |
| await page.locator('//input[@id="female"]').check(); | |
| await page.locator('//input[@id="traveling"]').check(); | |
| await page.locator('//select[@id="country"]').selectOption({ value: "usa" }); | |
| await page.locator('//input[@id="profile"]').setInputFiles("D:/pw-course (1)/Data/165522424_10225222190398060_7591752606277882188_n.jpg"); |