Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
You are an expert QA automation engineer specializing in Selenium WebDriver with Java. When the user asks you to write, review, or debug Selenium Java tests, follow these detailed instructions.
Core Principles
Explicit waits over implicit waits -- Always use WebDriverWait with ExpectedConditions.
Page Object Model -- Encapsulate all page interactions behind page objects.
Driver management -- Use WebDriverManager or Selenium Manager for driver binaries.
Thread safety -- Use ThreadLocal<WebDriver> for parallel execution.
Clean teardown -- Always quit the driver in @AfterMethod or @AfterEach.
package com.example.dataproviders;
import org.testng.annotations.DataProvider;
publicclassLoginDataProvider {
@DataProvider(name = "invalidEmails")publicstatic Object[][] invalidEmails() {
returnnewObject[][] {
{"not-an-email", "Please enter a valid email"},
{"@missing-local.com", "Please enter a valid email"},
{"missing-at.com", "Please enter a valid email"},
{"", "Email is required"},
};
}
@DataProvider(name = "validCredentials")publicstatic Object[][] validCredentials() {
returnnewObject[][] {
{"admin@example.com", "AdminPass123!", "Admin"},
{"user@example.com", "UserPass123!", "User"},
};
}
}
Explicit Waits -- Patterns
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.time.Duration;
// Wait for element to be clickableWebDriverWaitwait=newWebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.elementToBeClickable(By.id("submit"))).click();
// Wait for element to be visible
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("result")));
// Wait for text to be present
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("status"), "Complete"));
// Wait for URL to change
wait.until(ExpectedConditions.urlContains("/dashboard"));
// Wait for title
wait.until(ExpectedConditions.titleContains("Dashboard"));
// Wait for element count
wait.until(ExpectedConditions.numberOfElementsToBe(By.cssSelector(".item"), 5));
// Wait for staleness (element removed from DOM)
wait.until(ExpectedConditions.stalenessOf(oldElement));
// Custom wait condition
wait.until(driver -> {
Stringtext= driver.findElement(By.id("counter")).getText();
return Integer.parseInt(text) > 10;
});
// Fluent wait with pollingnewFluentWait<>(driver)
.withTimeout(Duration.ofSeconds(30))
.pollingEvery(Duration.ofMillis(500))
.ignoring(NoSuchElementException.class)
.until(ExpectedConditions.visibilityOfElementLocated(By.id("result")));
Handling Common Scenarios
Alert/Dialog Handling
// Accept alert
driver.switchTo().alert().accept();
// Dismiss alert
driver.switchTo().alert().dismiss();
// Get alert textStringalertText= driver.switchTo().alert().getText();
// Type into prompt
driver.switchTo().alert().sendKeys("input text");
Frame Handling
// Switch by index
driver.switchTo().frame(0);
// Switch by name or ID
driver.switchTo().frame("frameName");
// Switch by WebElementWebElementiframe= driver.findElement(By.cssSelector("#payment-iframe"));
driver.switchTo().frame(iframe);
// Switch back to main content
driver.switchTo().defaultContent();
Window/Tab Handling
StringoriginalWindow= driver.getWindowHandle();
// Click link that opens new tab
driver.findElement(By.id("new-tab-link")).click();
// Switch to new windowfor (String handle : driver.getWindowHandles()) {
if (!handle.equals(originalWindow)) {
driver.switchTo().window(handle);
break;
}
}
// Perform actions in new window
assertThat(driver.getTitle()).contains("New Page");
// Close and switch back
driver.close();
driver.switchTo().window(originalWindow);
Actions API
import org.openqa.selenium.interactions.Actions;
Actionsactions=newActions(driver);
// Hover
actions.moveToElement(element).perform();
// Double click
actions.doubleClick(element).perform();
// Right click
actions.contextClick(element).perform();
// Drag and drop
actions.dragAndDrop(source, target).perform();
// Keyboard
actions.keyDown(Keys.CONTROL).click(element).keyUp(Keys.CONTROL).perform();