2. Print all 111, 222,…999 no’s.. Code
Page Object Model (POM) is the popu5 design pattern in Selenium that enhances test maintenance. Each web page is represented by a class, and the elements on the page are variables in the class.
3. How to Handle drop down?
String mainPage = driver.getWindowHandle();
Alert alt = driver.switchTo().alert(); // to move control to alert popup
alt.accept(); // to click on ok.
alt.dismiss(); // to click on cancel.
//Then move the control back to main web page-
driver.switchTo().window(mainPage); → to switch back to main page.
4. How to click on a hyper link using linkText?
driver.findElement(By.linkText(“facebook”)).click();
driver.findElement(By.partialLinkText(“aceb”)).click();
5. What is a framework?
A framework is also known as software framework, is a platform that provides a foundation for developing software applications. In this platform the program that can be selectively modified by adding code.
A framework is generally more comprehensive than a protocol and more prescriptive than a structure.
6. Can WebDriver test Mobile applications?
Selenium WebDriver is primarily designed for automating web applications on desktop browsers. It does not directly support testing mobile applications. To perform mobile application testing, tools like Appium are used.
7. How can we get a text of a web element?
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class GetElementText{
public static void main(String[] args) {
System.setProperty(webdriver.chrome.driver,C:\\Users\\Credo\\Desktop\\Java\\chromedriver.exe);
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get(https://www.credosystemz.com/);
// identify element
WebElement p=driver.findElement(By.xpath//h1));
//getText() to obtain text
String s= p.getText();
System.out.println(Text content is : + s);
driver.close();
}
}
8. How do I launch the browser using WebDriver?
Use the code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ChromeLaunch{
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
String url = https://www.credosystemz.com/;
driver.get(url);
}
}
Free PDF : Get our updated Selenium Course Content pdf
9. How to switch between windows?
Switching between windows in Selenium WebDriver involves using methods, like:
getWindowHandles() – to retrieve a set of all window handles.
switchTo().window() – to switch to a specific window.
10. Reason for leaving previous company
Selenium WebDriver uses tools like BrowserMob Proxy in conjunction to capture and manipulate network traffic. It does not have built-in support for capturing network traffic
11. Draw framework diagram in your project
Selenium WebDriver provides various methods to manage browser windows, like: maximizing, minimizing, and resizing.
Maximizing the window:
driver.manage().window().maximize();
Minimizing the window:
driver.manage().window().minimize();
Setting the window size:
driver.manage().window().setSize(new Dimension(1024, 768));
12. Explain the Type of reports?
Top 5 Important reports are,