selenium
The command which is used to pause execution until the specified element becomes present?
"WaitForElementPresent" command will pause selenium until targeted element not present on the page. Once element will appear on the page, selenium will go for executing next command.
The command which retrieves the alert message and stores it in a variable that you will specify?
"storeAlert" command will read the alert text and store it in specified variable and then it will close the alert popup.
How to handle frame in WebDriver?
An inline frame acronym as iframe is used to insert another document within the current HTML document or simply a web page into a web page by enabling nesting. Select iframe by id driver.switchTo().frame("ID of the frame"); Locating iframe using tagName driver.switchTo().frame(driver.findElements(By.tagName("iframe").get(0)); Locating iframe using index frame(index)driver.switchTo().frame(0); Locating iframe using Name frame(Name of Frame)driver.switchTo().frame("name of the frame"); Select Parent Window driver.switchTo().defaultContent();
What is the difference between assert and verify commands?
Assert: Assert command checks whether the given condition is true or false. Let's say we assert whether the given element is present on the web page or not. If the condition is true then the program control will execute the next test step but if the condition is false, the execution would stop and no further test would be executed. Verify: Verify command also checks whether the given condition is true or false. Irrespective of the condition being true or false, the program execution doesn't halt i.e. any failure during verification would not stop the execution and all the test steps would be executed.
What are the different types of navigation commands?
Following are the navigation commands: navigate().back() - The above command requires no parameters and takes back the user to the previous webpage in the web browser's history. Sample code: driver.navigate().back(); navigate().forward() - This command lets the user to navigate to the next web page with reference to the browser's history. Sample code: driver.navigate().forward(); navigate().refresh() - This command lets the user to refresh the current web page there by reloading all the web elements. Sample code: driver.navigate().refresh(); navigate().to() - This command lets the user to launch a new web browser window and navigate to the specified URL. Sample code:driver.navigate().to("https://google.com");
How can we get a text of a web element?
Get command is used to retrieve the inner text of the specified web element. The command doesn't require any parameter but returns a string value. It is also one of the extensively used commands for verification of messages, labels, errors etc displayed on the web pages. Syntax:String Text = driver.findElement(By.id("Text")).getText();
What is Selenium IDE?
IDE records multiple locators for each element it interacts with. If one locator fails during playback, the others will be tried until one is successful.
What does the term DOM refer to?
In short, the Document Object Model (DOM) is the way how HTML elements are structured.
Which method is used when you want to verify whether a certain checkbox, radio button, or option in a drop-down box is selected in Web driver Selenium?
IsSelected( ) is the Selenium WebDriver Predefined Method, which is used to get the status of the radio buttons and check box options. IsSelected( ) predefined method returns true if the radio button or the check box is selected else it will return false.
How to find more than one web element in the list?
Sample Code // Storing the list List <WebElement>elementList = driver.findElements(By.xpath("//div[@id='example']//ul//li")); // Fetching the size of the list int listSize = elementList.size(); for (int i=0; i<listSize; i++) { // Clicking on each service provider link serviceProviderLinks.get(i).click(); // Navigating back to the previous page that stores link to service providers driver.navigate().back(); }
Method which selects the option which displays the text matching the parameter passed to it?
SelectByVisibleText( ) command can also be used to select a list option from the Drop Down field using its Label Text.
When should I use Selenium Grid?
Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution, testing under different environments and saving execution time remarkably.
Which Component is used to run multiple tests simultaneously in different browsers and platforms?
Selenium Grid is a part of the Selenium Suite that specializes in running multiple tests across different browsers, operating systems, and machines in parallel. It is achieved by routing the commands of remote browser instances where a server acts as a hub.
What is Selenium?
Selenium is a portable framework for testing web applications. Selenium provides a playback tool for authoring functional tests without the need to learn a test scripting language.
What is the difference between "/" and "//" in Xpath?
Single Slash "/" - Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node. Double Slash "//" - Double slash is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.
How to click on a hyper link using linkText? driver.findElement(By.linkText("Google")).click();
The command finds the element using link text and then click on that element and thus the user would be re-directed to the corresponding page. The above-mentioned link can also be accessed by using the following command. driver.findElement(By.partialLinkText("Goo")).click(); The above command finds the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element with the specified substring and then clicks on it.
What are the different types of Drivers available in WebDriver?
The different drivers available in WebDriver are: FirefoxDriver InternetExplorerDriver ChromeDriver SafariDriver OperaDriver AndroidDriver IPhoneDriver HtmlUnitDriver
How do I launch the browser using WebDriver?
The following syntax can be used to launch Browser: WebDriver driver = new FirefoxDriver();WebDriver driver = new ChromeDriver();WebDriver driver = new InternetExplorerDriver();
What are the different types of locators in Selenium?
The locator can be termed as an address that identifies a web element uniquely within the webpage. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium: ID ClassName Name TagName LinkText PartialLinkText Xpath CSS Selector DOM
How to type in a textbox using Selenium?
The user can use sendKeys("String to be entered") to enter the string in the textbox. Syntax:WebElement username = drv.findElement(By.id("Email"));// entering usernameusername.sendKeys("sth");
How to select value in a dropdown?
The value in the dropdown can be selected using WebDriver's Select class. Syntax: selectByValue:Select selectByValue = new Select(driver.findElement(By.id("SelectID_One")));selectByValue.selectByValue("greenvalue"); selectByVisibleText:Select selectByVisibleText = new Select (driver.findElement(By.id("SelectID_Two")));selectByVisibleText.selectByVisibleText("Lime"); selectByIndex:Select selectByIndex = new Select(driver.findElement(By.id("SelectID_Three")));selectByIndex.selectByIndex(2);
How can you find if an element in displayed on the screen?
WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc. isDisplayed() isSelected() isEnabled() Syntax: isDisplayed():boolean buttonPresence = driver.findElement(By.id("gbqfba")).isDisplayed(); isSelected():boolean buttonSelected = driver.findElement(By.id("gbqfba")).isSelected(); isEnabled():boolean searchIconEnabled = driver.findElement(By.id("gbqfb")).isEnabled();
Where is XPath used in?
XPath is a technique in Selenium to navigate through the HTML structure of a page. XPath enables testers to navigate through the XML structure of any document, and this can be used on both HTML and XML documents.
What is an XPath?
XPath is used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize and transport arbitrary data. It stores data in a key-value pair which is very much similar to HTML tags. Both being markup languages and since they fall under the same umbrella, XPath can be used to locate HTML elements. The fundamental behind locating elements using XPath is the traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.
What does the assertTitle checks?
assertTitle gets the title of a website and checks it against the provided text.
The method which clears all selected entries in Web driver Selenium?
deselectAll () method is useful to remove selection from all selected options of select box. It will works with multiple select box when you need to remove all selections.
When do we use findElement() and findElements()?
findElement(): findElement() is used to find the first element in the current web page matching to the specified locator value. Take a note that only first matching element would be fetched. Syntax: WebElement element = driver.findElements(By.xpath("//div[@id='example']//ul//li"));findElements(): findElements() is used to find all the elements in the current web page matching to the specified locator value. Take a note that all the matching elements would be fetched and stored in the list of WebElements. Syntax: List <WebElement>elementList = driver.findElements(By.xpath("//div[@id='example']//ul//li"));