Found 6710 Articles for Javascript

Explain data driven framework.

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:16:20

599 Views

Data driven framework is used for segregating test script logic from the test data. In this framework, we can run our test scripts using multiple sets of data in multiple combinations with the help of parameterization. The test data is maintained in separate files like excel, access, txt and so on.The test scripts need to be connected to these external files for fetching the data. The primary aim of this framework is to run our test scripts against various sets of data thereby reducing the number of test cases.Data driven framework has more test coverage, reusable features and is easy ... Read More

Explain Keyword driven framework.

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:15:04

357 Views

Keyword driven framework is also known as table driven framework. Here we have a table where we describe the keywords or actions for the methods that have to be executed.Automation test scripts are developed based on the keywords or actions mentioned in excel. The automation testers need to extend the framework capabilities by updating or building newer keywords.People working on manual testing with lesser programming knowledge can use this framework. The main idea is to identify the keywords or actions and utilize them in excel maintained for that particular test scenario. Often this excel sheet becomes a substitute for a ... Read More

What does fluent wait perform?

Debomita Bhattacharjee
Updated on 10-Jun-2020 14:38:47

508 Views

Fluent wait is a dynamic wait which makes the driver pause for a condition which is checked at a frequency before throwing an exception. The element is searched in DOM not constantly but at a regular interval of time.For example, if the wait is for 5 seconds, FluentWait monitors the DOM at regular intervals (defined by polling during time). In FluentWait, customized wait methods based on conditions need to be built.Syntax −Wait w = new FluentWait< WebDriver >(driver) .withTimeout (10, SECONDS) .pollingEvery (2, SECONDS) .ignoring (NoSuchElementException.class)Exampleimport org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.support.ui.Wait; import ... Read More

What does explicit wait perform?

Debomita Bhattacharjee
Updated on 10-Jun-2020 14:36:27

468 Views

Explicit waits are applied to a specific element in the web page. It shall pause the execution till the condition is satisfied. Explicit wait is also a dynamic one since if the wait time is fifteen seconds and the conditions (like waiting for an element to be clickable, visible or selectable and so on) are satisfied before this specified time, the control will move to the next step.Explicit wait is more customizable since we can set it up for the condition. The listof some of the expected conditions for explicit waits are listed below −textToBePresentInElement()Syntaxw.until(ExpectedConditions.textToBePresentInElement(By.id(““), “Tutorialspoint”));textToBeClickable()Syntaxw.until(ExpectedConditions.textToBeClickable(By.id(““)));alertisPresent()Syntaxw.until(ExpectedConditions.alertisPresent())= null);frameToBeAvailableAndSwitchToIt()Syntaxw.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id(““)));Explicit is complex in ... Read More

How to identify the nth sub element using xpath?

Debomita Bhattacharjee
Updated on 10-Jun-2020 13:06:19

7K+ Views

We can identify the nth sub element using xpath in the following ways −By adding square brackets with index.By using position () method in xpath.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class SubElement {    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       String url = "https://www.tutorialspoint.com/index.htm";       driver.get(url);       driver.manage().window().maximize();       driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);       // xpath using position() targeting the first element with type text       driver.findElement(By.xpath("//input[@type='text'][position()=1]"))     ... Read More

Among id, name, xpath and css, which locator should be used?

Debomita Bhattacharjee
Updated on 10-Jun-2020 13:04:03

388 Views

Each of the locators has some significance. If the page contains uniqueattribute values, we should use them first. However if there are no unique elements, we should use css selector as it is more effective in terms of speed.Css also has a drawback that we cannot traverse from child to parent node which means we cannot travel backward. But xpath allows this feature. Xpath is the most common locator in Selenium and performs traversal through DOM elements and attributes to identify an object.An xpath is represented by two ways namely ‘/ ‘and ‘// ‘. A forward single slash means absolute ... Read More

How to get the value of the edit box in Selenium?

Debomita Bhattacharjee
Updated on 10-Jun-2020 12:17:34

598 Views

We can get the value of the edit box in Selenium by the following ways −By using getText () method.Using the class JavascriptExecutor.Code Implementation with method getText ().Exampleimport org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class GetValueScripting {    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       String url = "https://www.tutorialspoint.com/index.htm";       driver.get(url);       driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);       String text = driver.findElement(By.className("gsc-input")).getText();       System.out.println("Extracted text is " + text);       driver.close();   ... Read More

How to redirect to another webpage with JavaScript?

AmitDiwan
Updated on 12-May-2020 13:56:13

2K+ Views

To redirect to another webpage using JavaScript, the code is as follows −Example Live Demo Redirect to a Webpage Example Redirect Click the above button to Redirect to another Webpage    document .querySelector(".redirectBtn") .addEventListener("click", redirectFunction);    function redirectFunction() {       location.href("https://tutorialspoint.com/");    } OutputThe above code will produce the following output −On clicking the “Redirect” button we will be redirected to a new site −

How to create a speed converter with HTML and JavaScript?

AmitDiwan
Updated on 12-May-2020 13:49:56

330 Views

To create a speed converter with HTML and JavaScript, the code is as follows −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    input, span {       font-size: 20px;    } Speed Converter Type speed in Kilometer per hour to convert it into meter per hour Kilometer Per Hour Meters Per second:    function KmphtoMphConverter(speed) {       document.querySelector(".metersPerSecond").innerHTML = speed * 0.277778;    } OutputThe above code will produce the following output −On entering some speed in kph −

How to create a length converter with HTML and JavaScript?

AmitDiwan
Updated on 12-May-2020 13:47:55

1K+ Views

To create a length converter with HTML and JavaScript, the code is as follows −Example Live Demo    body{       font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;    }    input,span{       font-size: 20px;    } Length Converter Type length in Kilometers to convert it into meters Kilometers Meters:    function KmtoMConverter(length) {       document.querySelector(".meters").innerHTML=length*1000;    } OutputThe above code will produce the following output −On entering length in kilometers −

Advertisements