# Interview Questions

{% embed url="<https://quizlet.com/607287864/selenium-flash-cards/?i=fnawl&x=1jqt>" %}

## Can you list some of the webpage operations available in Selenium?

Me: Sure! Some of the main operations are:

♻️ Navigate to URLs:

```java
driver.get("url") 🖥
driver.navigate().to("url") 🏎️
```

👀 Inspect the webpage:

```java
driver.getTitle() 📃
driver.getPageSource() 👁
driver.getCurrentUrl() 🌐
```

✍️ Interact with elements:

```java
driver.find_element_by_id().send_keys("text") 🔍
driver.find_elements_by_class_name().click() 🖱
```

📷 Take screenshots:

```java
driver.get_screenshot_as_file("filename.png") 📸
```

⌨️ Send keyboard inputs:

```java
Actions().send_keys().perform() 💻
```

🖱 Perform mouse actions:

```java
Actions().move_to_element().click().perform() 🖱
```

## What WebEdit operations are available in Selenium?

Me: WebEdit refers to text fields, input boxes, and text areas on a webpage. Selenium provides these useful APIs to interact with WebEdits:

### To enter text in a text field:

**sendKeys()**

Syntax:

```java
driver.findElement([By.id](<http://by.id/>)("textbox")).sendKeys("TestData")
```

This will type the string "TestData" into the text field. 🔤

### To clear text from a text field:&#x20;

**clear()**

Syntax:

```java
driver.findElement([By.id](<http://by.id/>)("textbox")).clear()
```

This will empty any existing text from the field.✂️

### Entering a search query:

```java
driver.findElement([By.name](<http://by.name/>)("q")).sendKeys("selenium testing") 🔍
```

### Clearing the search box:

```java
driver.findElement([By.name](<http://by.name/>)("q")).clear() ✂️
```

### Filling out a form:

```java
driver.findElement(By.className("fname")).sendKeys("John")
driver.findElement(By.className("lname")).sendKeys("Doe")✍️
```

## What operations can you perform on links using Selenium WebDriver?

Me: Selenium provides a few useful APIs for interacting with links (i.e. \<a> elements):

### To click a link:

**click()**

Syntax:

```java
driver.findElement([By.id](<http://by.id/>)("someLink")).click()
```

This will simulate a click on the link. 👈

### To check if a link is enabled:

**isEnabled()**

Syntax:

```java
driver.findElement([By.id](<http://by.id/>)("link")).isEnabled()
```

This returns true/false if the link can be clicked. 🟢

### To check if a link is visible:&#x20;

**isDisplayed()**

Syntax:

```java
driver.findElement([By.id](<http://by.id/>)("link")).isDisplayed()
```

This returns true/false if the link is visible on the page. 👁️

### Clicking a footer link:

```java
driver.findElement(By.linkText("Terms")).click() 📄
```

### Checking a disabled link:

```java
isEnabled = driver.findElement(By.partialLinkText("Disabled")).isEnabled()
print(isEnabled)  ❌
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://qatesting.gitbook.io/qa/automation-testing/flow/selenium/interview-questions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
