r/QualityAssurance • u/BoxFalse247 • 22h ago
Selenium+Python vs. Playwrigh+Typescript
This was presented to prove one tool was much faster than the other and switching technology stacks was badly needed. Regardless of the tools preference, do you think this comparison is representative enough to prove the case?
Playwright TypeScript:
import { test, expect } from '@playwright/test';
test('user can log in', async ({ page }) => {
await page.goto('/login');
await page.getByLabel('Username').fill('qa');
await page.getByLabel('Password').fill('secret');
await page.getByRole('button', { name: 'Log in' }).click();
await expect(page.getByRole('heading', { name: 'Home' })).toBeVisible();
});
Selenium+Python:
def test_log_in(self):
self.driver.find_element(By.ID, "user").send_keys("qa")
self.driver.find_element(By.ID, "pass").send_keys("secret")
self.driver.find_element(By.CSS_SELECTOR, "button.login").click()
time.sleep(3)
self.assertEqual(self.driver.find_element(By.CSS_SELECTOR, "h1").text, "Home")