Removing Adjacent Duplicates from a String in JavaScript

AmitDiwan
Updated on 07-Apr-2021 09:08:45

2K+ Views

ProblemJavaScript function that takes in a string, str, as the first and the only argument.A duplicate removal consists of choosing two adjacent and equal letters, and removing them.We repeatedly make duplicate removals on string str until we no longer can.And our function should finally return the final string after all such duplicate removals have been made.For example, if the input to the function is −const str = 'kllkmk';Then the output should be −const output = 'mk';Output Explanation:Firstly, we will remove ‘ll’ from the string to reduce it to ‘kkmk’, then after removing ‘kk’, we will return the new string.ExampleThe code ... Read More

Finding Next Greater Node for Each Node in JavaScript

AmitDiwan
Updated on 07-Apr-2021 09:06:32

204 Views

ProblemWe are required to write a JavaScript function that takes in the head of the linked list as the first and the only argument.This linkedlist contains numerical data. Each node in the list may have a next larger value: for node_i, next_larger(node_i) is the node_j.val such that j > i, node_j.val > node_i.val, and j is the smallest possible choice. If such a j does not exist, the next larger value is 0.Our function should prepare and return an array in which the corresponding element is the next greater element for the element in the list.For example, if the list ... Read More

Difference Between RSpec and Cucumber in Selenium

Debomita Bhattacharjee
Updated on 07-Apr-2021 09:06:11

377 Views

The differences between RSpec and Cucumber are listed below −Sr. No.RSpecCucumber1A testing framework which gives the option to build and execute tests.A tool which is used to create test cases in plain English text.2Mainly used for integration and unit testing.Mainly used for user acceptance testing.3Utilized for Test Driven Development by developers and for Behavior Driven Development by testers.Utilized for Behavior Driven Development.4Narrates step from a business specification using the Describe, Context and It blocks.Narrates step from a business specification with the Given, When, Then, And, But, and so on keywords.5Code for implementation of a step is available within the Describe, ... Read More

Greatest Sum and Smallest Index Difference in JavaScript

AmitDiwan
Updated on 07-Apr-2021 09:04:10

134 Views

ProblemJavaScript function that takes in an array of Integers, arr, as the first and the only argument.Our function should pick an index pair (i, j) such that (arr[i] + arr[j]) + (i - j) is maximum amongst all index pairs in the array. Our function should then return the maximum value.For example, if the input to the function is −const arr = [8, 1, 5, 2, 6];Then the output should be −const output = 11;Output ExplanationBecause if we choose i = 0 and j = 2 then the value will be −(8 + 5) + (0 - 2) = 11Which ... Read More

Automated Software Testing with SpecFlow in Selenium

Debomita Bhattacharjee
Updated on 07-Apr-2021 09:03:56

385 Views

We can have automated software testing with SpecFlow by configuring Selenium in C#. We will use the Visual Studio editor, to develop the Selenium tests using the NUnit framework. Click on Create a new project from the Visual Studio welcome page.Enter NUnit in the search edit box within the Create a new project window. Then choose the option NUnit Test Project(.NET Core) from the result dropdown. Click on Next to proceed.Populate the Project name, Location and click on Create.Once the project is successfully configured, the Setup and Test methods are provided automatically along with the import statement - using NUnit.Framework.Then ... Read More

Verify Error Message on a Webpage Using Selenium WebDriver

Debomita Bhattacharjee
Updated on 07-Apr-2021 09:01:10

8K+ Views

We can verify error messages on a webpage using Selenium webdriver using the Assertion. In case, the actual and expected values do not match, an Assertion Error is thrown.Let us try to verify the highlighted error message.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; import org.testng.Assert; public class VerifyErrorMsg{    public static void main(String[] args) {       System.setProperty("webdriver.gecko.driver", "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe");       WebDriver driver = new FirefoxDriver();       //implicit wait       driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);       //URL launch       driver.get("https://www.linkedin.com/");   ... Read More

Handling Dropdown and Multiple Select in WebDriver Using Selenium

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:57:44

18K+ Views

We can handle multi-select dropdown with Selenium webdriver using the Select class. A multi-select dropdown is the one which allows selection of multi options.The Select methods to handle multi-select dropdown are listed below −getOptions – returns the list of all options in the dropdown.Select s = new Select(e); List l = s.getOptions();getFirstSelectedOption– returns the selected option in the dropdown. If there are multi options selected, only the first item shall be returned.Select s = new Select(e); l = s. getFirstSelectedOption();isMultiple – returns a boolean value, yields a true value if the dropdown allows selection of multiple items.Select s = new ... Read More

What is Selenium Internet Explorer Driver (IE Driver)?

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:51:46

466 Views

Selenium Internet Explorer Driver is used to execute test cases in the Internet Explorer browser. It is a standalone server that establishes a link between our Selenium test and the Internet Explorer browser.We can download the Internet Explorer Driver file from the below link − https://www.selenium.dev/downloads/Select and click on the download link which is compatible with our local operating system. As the download is done successfully, a zip file gets created. We have to unzip it and save the executable file - IEDriverServer.exe in a location.Next, we shall set the path of the IEDriverServer.exe file using the System.setProperty method. We ... Read More

Perform Explicit Wait Method in Selenium with C#

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:50:24

2K+ Views

We can perform explicit wait with Selenium webdriver in C#. This is done to achieve synchronization between our tests and the elements on the page. For implementation of explicit wait, we have to take the help of the WebDriverWait and ExpectedCondition classes.We shall create an object of the WebDriverWait class. The webdriver waits tillspecified wait time waiting for the expected condition for an element is satisfied.After the time has elapsed, an exception is raised by Selenium.The explicit waits are dynamic in nature which means if we have an explicit wait of five seconds and the expected condition is met at ... Read More

Data-Driven Testing in SpecFlow API Using Selenium

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:48:49

284 Views

We can do data driven testing in SpecFlow with/without the Examples keyword. In case we are not using the keyword Examples, then we have to send the data from the steps (enclosed in '') in the Feature file.Feature File ImplementationFeature: Launching application Scenario: Launch URL Given User hits URL 'https://www.tutorialspoint.com/index.htm'ExampleStep Definition File Implementationusing System; using TechTalk.SpecFlow; namespace SpecFlowProject1.Features{    [Binding]    public class LaunchingApplicationSteps{       [Given(@"User hits URL '(.*)'")]       public void GivenUserHitsURL(string url){          Console.WriteLine(url);       }    } }OutputNext, we will perform the data driven testing using the Examples ... Read More

Advertisements