1. What are the steps to connect with Database ?
First add jar for the database/jdbc driver
Create Connection: Create code to connect with database
Create Query: Write code for the sql query.
Execute the Query
Close the connection
If there is "Select" statement:
Add jar for the database/jdbc driver
Create Connection: Create code to connect with database
Create Query: Write code for the sql query.
Execute the Query
store the result using result set
Close the connection
2. What are the ways to handle Frame in Selenium ?
There are 3 ways :
Frame WebElement, such as driver.switchTo().frame(driver.findElement(By.xpath("..."));
Frame Name or ID, such as
driver.switchTo().frame("frame name");
driver.switchTo().frame("frame id");
Frame index, such as driver.switchTo().frame(index number);
DefaultContent(), such as driver.switchTo().defaultContent(); => to return back to the main window or page or the topmost frame.
3. What are the methods of the action class?
Action class is used to manage the mouse and the keyboard actions. The Selenium methods to manage such actions are as below:
Methods For Mouse Actions:
clickAndHold()
dragAndDrop()
moveToElement()
doubleClick()
contextClick(): this is to right click the mouse
Methods For Keyboard Actions:
sendKeys()
keyUp()
keyDown()
4. What are the methods used in drop down ?
Select dropdwn = new Select(driver.findElement(By.xpath("xpath of the dropdown")));
dropdwn.selectByIndex()
dropdwn.selectByVisibleText()
dropdwn.selectByValue()
dropdwn.getOptions() => this returns the list of the dropdown elements
5. What is final keyword in java ?
Final keyword can be used in variable, method or class .
When used in variable, the value of the variable is the final and can not be changed.
When used in method, the method can not be overridden in the child class. We can not use that method in the subclass.
When used in class, the class can not be inherited or extended by any other class.
6. What is finalize() method?
It is a method to perform cleanup activity. This method is called by garbage collector before deleting an object. Once the finalize() methods runs/completes , the garbage collector will immediately deletes or destroys the associated resources, connections etc. This process is called finalization in Java.
7. Difference between a constructor and a method:
Constructor:
Same name like class
Can create object of the constructor
Does not have any return type
Name starts with Upper case letter
Methods:
Name is different than the class name
Creating object does not apply to the methods, it is block of code.
It can have a return type or no return type.
Name starts with small letter.
8. What is a Java Wrapper Class ?
Java Wrapper classes make it possible to use primitive data types.
Such as :
Primitive datatypes Wrapper class
int Integer
char Character
float Float
byte Byte
long Long
double Double
boolean Boolean
etc.
9. What are hard assert and soft assert ?
Hard Assert : the test execution stops if any test step fails and moves on to the next test case in the execution list.
Soft Assert : the test execution does not stop even if a test step fails and fails the test case at the end with assert all.
10. How can you upload a file in Selenium ?
There are different ways, some are mentioned below:
Using SendKeys(path of the file including file name) method
Using Robot class
Using AutoIT tool
No comments:
Post a Comment