package [Link].
backend;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Component
public class AutomationScripts {
public AutomationScripts() {
[Link]("[Link]",
"src/main/resources/chromedriver");
/**
* Task 1: Retrieve Webpage Title
* Steps to implement:
* 1. Open the URL: [Link]
* 2. WAIT for 2 seconds and ensure the title contains "Selenium Interaction
* Playground" using `[Link]()`.
* 3. Retrieve the page title.
* 4. Return the page title as a String.
*
* @param driver WebDriver instance
* @return Page title as String
*/
public String getTitle(WebDriver driver) throws InterruptedException {
[Link]("[Link]
[Link](2000);
String title = [Link]();
return title;
/**
* Task 2: Dynamic Table Functionality
* Steps to implement:
* 1. WAIT for 3 seconds for the Dynamic Table link to be clickable using
* `[Link]()`.
* 2. Click and navigate to the page.
* 3. WAIT for 2 seconds.
* 4. Click the "Add Row" button using
* `[Link]()`.
* 5. WAIT for table rows to be visible using
* `[Link]()`.
* 6. Retrieve all table rows and store their text.
* 7. Navigate back to the home page.
* 8. Return the URL and list of row texts.
*
* @param driver WebDriver instance
* @return List of Strings containing table row texts and URL
*/
public List<String> dynamicTable(WebDriver driver) throws InterruptedException
{
WebDriverWait wait = new WebDriverWait(driver, [Link](10));
WebElement dynamicTableLink =
[Link]([Link]([Link]("Dynamic Table")));
[Link]();
[Link](2000);
WebElement addRowButton = wait
.until([Link]([Link]("//button[text()='Add
Row']")));
[Link]();
List<WebElement> rows = wait
.until([Link]([Link]
("//table/tbody/tr")));
List<String> rowTexts = new ArrayList<>();
for (WebElement row : rows) {
[Link]([Link]());
}
WebElement homeLink = [Link]([Link]("Home"));
[Link]();
List<String> result = new ArrayList<>();
[Link]([Link]());
[Link](rowTexts);
return result;
/**
* Task 3: Slider Functionality
* Steps to implement:
* 1. WAIT for 3 seconds for the Slider link to be clickable using
* `[Link]()`.
* 2. Click and navigate to the Slider page.
* 3. WAIT for 2 seconds.
* 4. Retrieve the image caption using
* `[Link]()`.
* 5. WAIT for 2 seconds after retrieving the caption.
* 6. Navigate back to the home page using
* `[Link]()`.
* 7. Return the caption and URL as a List.
*
* @param driver WebDriver instance
* @return List of Strings containing caption and URL
*/
public List<String> slider(WebDriver driver) throws InterruptedException {
WebDriverWait wait = new WebDriverWait(driver, [Link](10));
WebElement sliderLink =
[Link]([Link]([Link]("Slider")));
[Link](3000);
[Link]();
[Link](2000);
WebElement captionElement =
[Link]([Link]([Link]("caption")));
String caption = [Link]();
WebElement homeLink =
[Link]([Link]([Link]("Home")));
[Link]();
List<String> result = new ArrayList<>();
[Link](caption);
[Link]([Link]());
return result;
}
is there any error?
//a[normalize-space()='Accordion']