1. What are the locators in Selenium ?
The locators in Selenium are:
1. name
2. class
3. id
4. linkText
5. partialLinkText
6. xpath
7. css Selector
2. How you initiate/lunch a browser in Selenium ?
Below code will initiates a browser:
For example , to initiate Chrome browser :
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
3. What are the “wait” commands in Selenium ?
The “wait” commands in Selenium are :
1. Dynamic wait :
Implicit wait,
Explicit wait and
Fluent wait
2. Static wait :
Thread.sleep(milliSeconds)
4. What is the framework in Selenium ?
Framework is a overall picture of designing your code. In your project you follow a framework which satisfies the universal coding standards or rules and also satisfies the rules you or your project has defined. It is a way of designing your code in such a way that it will make easier to understand, minimize errors, easy to debug, reduce time in coding and debugging. There are different types of frameworks. Some most common frameworks are :
1. Data Driven framework
2. Key Word Driven framework
3. Hybrid framework
5. What is the selenium code to open a webpage(URL)?
The selenium code to open a webpage(URL) are :
driver.get(“https://www.google.com”);
Or
driver.navigate.to(“https://www.google.com”);
Note: The “driver” in above codes is taken from question number 2.
6. What is the selenium code to close the browser ?
The selenium code to close the browser are :
To close the current browser/tab:
driver.close();
To close all the browsers/tabs opened in that session:
driver.quit();
Note: The “driver” in above codes is taken from question number 2.
7. How can you convert String variable value to int variable value ?
Use below code to convert String variable to int variable:
String xyz = "10";
int abc = Integer.parseInt(xyz);
8. How can you convert int variable value to String variable value?
Use below code to convert int value to String value:
int abc = 10;
String xyz = Integer.toString(abc);
9. How you make sure if the element is present or not on the webpage?
There are 3 ways/methods to make sure if the element is present or not . The element could be text box, buttons, check box, radio button, drop box etc.
1. isDisplayed()
2. isEnabled()
3. isSelected()
10. What is difference between Assert and Verify?
Both are used to validate steps. Assert(assertion) is used in TestNG, Junit and in Cucumber BDD. Selenium WebDriver does not support assert. In assert, if the test condition fails then the step is failed, the execution is stopped right there and the test case is marked as failed.
When you use verify(verification point), if the test condition is not fulfilled , then you can stop the execution right at that point or continue execution, it depends on how you have made the code.
No comments:
Post a Comment