Selenium Question 5

Q1. How to identify object other than Xpath?

It is on the bases of ID.
driver.findelement(“ID of link”)).click
driver.findelement(by.testlink(“ID of link”)).click
driver.findelement(by.partiallinktext(“Incomplete link”)).click
Class name should be unique and should be present.

Q2. Can we replace the start in Xpath ?

Yes :- * can be replaced with input which is a tag name.

Q3. How to handel a weblist ?

Ex:- dropdown

Q4. What is compound class name?

Class name having space in between and they are supported while creating Xpaths.
We can specify the text of the link in xpath
Driver.findelement(By.xpath(“//a[test()=’camera Accessories’]”)).click.

Q5. If two attribute have same href attribute then?

It will point to first occurrence of the hrif doc.

Q6. How to switch over to popup or tab window.

Set<string> windowsids = driver.getwindowhandles();
Iterator<string> iter = windowsids.iterator();
String tabbedwindowID =;

Q7. How to handle a certificate issue?

After creating firefox profile write these two lines :-
These are standard line and they are from API, we will not get the error.
For IE :-

Q8. What happen if Xpath keep on changing?

Use some java scrip function
Eg:- Input[starts-with(@id, ‘hellow_’))

Q9. How to pause the execution of program for some time ?

Threed.sleep(1000L); // its 10 second
It is fine but problems come if we are clicking on a link and the page does not appear with in 10 seconds or it comes up with in 2 seconds.
Driver.get () wait till the page is loaded
So the better way is put a global time out it the page is not visible in that time it will throw an error.
Driver.manage.timeouts.implictlywait(10L, TimeUnit.Seconds)
Time unit is a inbuilt class in selenium.
If an element takes more time then 10 seconds then we can write thread. sleep or alter the time out increasing implicitly time out.

Q10. How to handle java script alert messages with selenium.

Alert alt = Driver.swithchTo().alert();
We use accept: - it click on OK button
Alt.dismiss :- it will click on cancel button
Alt.get text :- It will get the text.

No comments:

Post a Comment