0% found this document useful (0 votes)
10 views2 pages

Selenium Vs Playwright Comparison Formatted Final

The document compares methods of Selenium and Playwright for browser automation. It outlines various functionalities such as creating drivers, identifying elements, handling JavaScript alerts, capturing screenshots, and performing user actions. Additionally, it highlights differences in handling dropdowns, working with Excel, and executing drag-and-drop actions between the two frameworks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Selenium Vs Playwright Comparison Formatted Final

The document compares methods of Selenium and Playwright for browser automation. It outlines various functionalities such as creating drivers, identifying elements, handling JavaScript alerts, capturing screenshots, and performing user actions. Additionally, it highlights differences in handling dropdowns, working with Excel, and executing drag-and-drop actions between the two frameworks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Comparison of Selenium and Playwright Methods

Selenium Playwright

1. Creating Driver (Browser Initialization)

Firefox Driver WebDriver driver = new FirefoxDriver();const { firefox } = requir

IE Driver WebDriver driver = new InternetExplorerDriver(); Playwr

Chrome Driver WebDriver driver = new ChromeDriver();


const { chromium } = requir

2. Identifying Elements

Find single Element driver.findElement(locator) cons

Find multiple Elements driver.findElements(locator) const

3. Locating UI Elements

By ID driver.findElement(By.id(str));

By Name driver.findElement(By.name(str));

By Class Name driver.findElement(By.className(str));

By CSS Selector driver.findElement(By.cssSelector(str));

By Link Text driver.findElement(By.linkText(str)); awa

By Partial Link Text driver.findElement(By.partialLinkText(str)); await p

By Tag Name driver.findElement(By.tagName(str));

By XPath driver.findElement(By.xpath(xpath));

4. Handling JavaScript Alerts

Switch to alert Alert al = driver.switchTo().alert(); const alert = aw

5. Capture Screenshot
Capture Screenshot File scrFile1 = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
await pag

6. User Actions

Write in text fields driver.findElement(locator).sendKeys(text);

Click button/radio button/check box driver.findElement(locator).click();

Clear text driver.findElement(locator).clear();

Navigate Back and Forward driver.navigate().back(); driver.navigate().forward(); await p

Navigate to frame driver.switchTo().frame(frame); awai

Switch to window driver.switchTo().window(hashCode); const [n

Get inner text driver.findElement(locator).getText(); a

7. Working on Select DropDown

Select by ID usr.selectById(ID); await pa

Select by Index usr.selectByIndex(i); await p

Select by Visible Text usr.selectByVisibleText(str); await pa

8. Working with Excel

Working with Excel Workbook wb = WorkbookFactory.create(fis);


Use an external library

9. Drag and Drop

Drag and Drop using source and destination a.dragAndDrop(src, des).build().perform(); await page.drag

Mouse Over on specific element a.moveToElement(element).build().perform();

Mouse right click a.contextClick(element).build().perform(); await

You might also like