Selenium Qa
Selenium Qa
Selenium Qa
By.id()
By.name()
By.tagName()
By.className()
By.linkText()
By.partialLinkText()
By.xpath
By.cssSelector()
35. When you use these locators ID, Name, XPath, Or CSS Selector?
ID & Name locators will be used when there are unique identifiers & unique names
available on the web page.
CSS Selector can be used for performance and when ID & Name locators are not
unique.
XPath is used when there is no preferred locators.
actions.moveToElement(driver.findElement(By.id("id of the
searchbox"))).perform();
----------------------------------------------------
WebDriverException
NoAlertPresentException
NoSuchWindowException
NoSuchElementException
TimeoutException
------------------------------------------------------
------------------------------------------------------
browse.sendKeys("D:\\SeleniumInterview\\UploadFile.txt");
----------------------------------------
38. Explain the difference between assert and verify commands.
The assert command is used to check if the given condition is true or not. If the
condition is true, then the execution of the program will continue. If the
condition is false, then the execution of the program will stop.
The verify command is used to check if the given condition is true or not. If the
condition is true, then the execution of the program will continue. If the
condition is false, then the execution of the program will not stop, but an error
message will be displayed.
Attributes are another important part of XPath. Attributes are added to elements
and can contain valuable information about that element. In order to access an
attribute, you must use the at sign (@) followed by the attribute name.
For example, if you want to select the first <p> element on a page, you would use
"/p". If you want to select all <p> elements on a page, regardless of their
location, you would use "//p".
42. What are the different types of annotations which are used in Selenium?
Different types of annotations that are used in Selenium include:
Once you have an Actions instance, you can use the dragAndDrop() method to perform
a drag and drop operation. This method takes two WebElements as arguments: the
element toDrag, and the element toDrop. For example, to drag an element with the id
"draggable" and drop it on an element with the id "droppable", you would do the
following:
actions.dragAndDrop(draggable, droppable).perform();
You can also use the clickAndHold() and release() methods to perform a drag and
drop operation. The clickAndHold() method takes a WebElement as an argument and
"grabs" it, while the release() method releases the element. For example:
actions.clickAndHold(draggable).release(droppable).perform();
You can also chain together multiple Actions methods to create more complex
interactions. For example, the following code will first move to the draggable
element, then click and hold it, move to the droppable element, and finally release
it:
actions.moveToElement(draggable).clickAndHold().moveToElement(droppable).release().
perform();
-----------------------------------------
--------------------------
-------------------
------------------------------------