[ agent view ]
Documentation Index
Fetch the complete documentation index at: https://e2e.com/docs/llms.txt Use this file to discover all available pages before exploring further.
From Selenium
Rewrite Selenium flows in TypeScript with locators, retrying assertions, and agent goals.
e2e replaces a Selenium suite with TypeScript tests. Locators find nodes by role and label, and assertions retry until they pass or time out. A Java or Python suite needs a rewrite, so run both suites and move one flow at a time.
For a migration that spans several sessions, the migrate-to-e2e skill records what moved in a progress file and keeps the old suite running until you retire each test.
Port the config
<Note>Install e2e with the quickstart. Only agent calls need a model, so the example below runs without one.</Note>
| Selenium | e2e |
|---|---|
The URL in every driver.get | app: { url } on the target, then relative paths |
| Starting the app in a script | app: { url, command }, see Starting your app |
| One driver per browser | One target per browser, web({ browser: 'firefox' }) |
| Selenium Grid | workers for parallelism; web({ connect }) attaches to a remote Chromium over CDP, and a browser provider such as Kernel leases hosted browsers |
manage().window().setSize | web({ viewport }) |
| Implicit waits | actionTimeout and assertionTimeout set action and assertion deadlines |
| A page object for sign-in | test.setup and { session }, see Authentication |
Rewrite one flow
Start with one page object and the flows that use it.
driver.get("http://localhost:3000/login");
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(visibilityOfElementLocated(By.id("username"))).sendKeys("admin@example.test");
driver.findElement(By.id("password")).sendKeys(System.getenv("ADMIN_PASSWORD"));
driver.findElement(By.xpath("//button[contains(., 'Sign in')]")).click();
wait.until(urlContains("/dashboard"));
assertEquals("Welcome back, admin!",
driver.findElement(By.cssSelector(".greeting")).getText());
test('signs in', async ({ app, screen, browser }) => {
const admin = credentials.user('admin');
await app.open('/login');
await screen.getByLabel('Username').fill(admin.username);
await screen.getByLabel('Password').fill(admin.password);
await screen.getByRole('button', 'Sign in').tap();
await expect(browser).toHaveURL('/dashboard');
await expect(screen.getByRole('status')).toHaveText('Welcome back, admin!');
});
Locator actions wait for their targets, so no explicit wait is left. The password comes from configured credentials.
Map each WebDriver call
| Selenium | e2e |
|---|---|
driver.get(url) | app.open(path) |
driver.navigate().back(), .refresh() | app.back(), browser.reload() |
By.id('x') | browser.locator('#x'); or web({ testIdAttribute: 'id' }) and screen.getByTestId('x') |
By.name('x') | browser.locator('[name="x"]'), not portable; prefer a role or label |
By.linkText, By.partialLinkText | screen.getByRole('link', { name }), name: /part/ |
By.cssSelector, By.xpath | browser.locator('css or xpath'), not portable |
findElements(...).size() | await locator.count() |
findElements(...).get(n) | locator.nth(n) |
.click() | .tap() |
.sendKeys('text') | .fill('text') replaces the content |
.sendKeys(Keys.ENTER) | .press('Enter') |
.clear() | .clear() |
new Select(el).selectByVisibleText | .selectOption({ label }) |
.getText(), .getAttribute(), .isDisplayed() | .textContent(), .getAttribute() wait for the node then read one time, .isVisible() reads at once; toHaveText() retries |
wait.until(visibilityOf(...)) | await expect(locator).toBeVisible() |
wait.until(textToBe(...)) | await expect(locator).toHaveText(...) |
wait.until(urlContains(...)) | await expect(browser).toHaveURL(/.../) |
Actions.moveToElement | .hover() |
Actions.dragAndDrop | .dragTo(target) |
Actions.keyDown(CONTROL).sendKeys('a') | .press('ControlOrMeta+a') |
switchTo().frame() | browser.frameLocator('#frame') |
switchTo().alert().accept() | browser.onDialog('accept') before the action |
switchTo().window() | No equivalent. Popups are unsupported |
executeScript | browser.evaluate |
manage().addCookie | browser.setCookies |
getScreenshotAs | app.screenshot('label'), redacted |
Thread.sleep | Use a locator assertion for the condition you need |
| Page objects | A fixture from test.extend, or a goal for agent.act, see Page objects |
findElement takes the first match. e2e fails with LOCATOR_AMBIGUOUS on
several, so narrow with .filter(), .first(), or .nth().
Next
Goals, assertions, and locators instead of scripted selectors.
Every query, refinement, action, and read.
