0% found this document useful (0 votes)
29 views3 pages

Selenium WebDriver Tasks With Examples

Selenium question bank
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Selenium WebDriver Tasks With Examples

Selenium question bank
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Task 1: get()

Write a script to open a website using [Link](). Use a website like Google or a practice
site.
Example:
```java
[Link]("[Link]
```

Task 2: navigate().to()
Navigate to a URL using [Link]().to() instead of get(). Open any two websites in
sequence and understand the difference.
Example:
```java
[Link]().to("[Link]
```

Task 3: navigate().refresh()
Open a website and refresh it using [Link]().refresh(). Observe how the page
reloads.
Example:
```java
[Link]().refresh();
```

Task 4: navigate().back()
Open two different websites using navigate().to(). Then navigate back to the first website
using [Link]().back().
Example:
```java
[Link]().back();
```

Task 5: navigate().forward()
After navigating back to the first website, use [Link]().forward() to move forward
to the second website.
Example:
```java
[Link]().forward();
```

Task 6: getTitle()
Open a website and retrieve the title of the page using [Link](). Print the title to the
console.
Example:
```java
[Link]([Link]());
```

Task 7: getCurrentUrl()
After opening a website, retrieve and print the current URL using [Link]().
Example:
```java
[Link]([Link]());
```

Task 8: getPageSource()
Open a website and print a small portion of the page source using [Link]().
Example:
```java
[Link]([Link]().substring(0, 100));
```

Task 9: findElement()
Open a website, locate an element using findElement() (e.g., search bar on Google), and
interact with it (e.g., send keys).
Example:
```java
WebElement searchBox = [Link]([Link]("q"));
[Link]("Selenium WebDriver");
[Link]();
```

Task 10: findElements()


Open a website and use findElements() to find a list of elements (e.g., all the links on the
page). Print the count.
Example:
```java
List<WebElement> links = [Link]([Link]("a"));
[Link]("Number of links: " + [Link]());
```

Task 11: manage().window().maximize()


Open a website and maximize the browser window using
[Link]().window().maximize().
Example:
```java
[Link]().window().maximize();
```

Task 12: manage().window().setSize()


Open a website and resize the browser window to a custom size using
[Link]().window().setSize().
Example:
```java
Dimension d = new Dimension(1024, 768);
[Link]().window().setSize(d);
```

Task 13: manage().deleteAllCookies()


Open a website, delete all cookies using [Link]().deleteAllCookies(), and verify by
checking cookies before and after deletion.
Example:
```java
[Link]().deleteAllCookies();
```

Task 14: quit()


Open a browser session, interact with a website, and close all browser windows using
[Link]().
Example:
```java
[Link]();
```

Task 15: close()


Open a website and close the current browser window using [Link]() without quitting
the WebDriver session.
Example:
```java
[Link]();
```

You might also like