Verify Element Does Not Exist in Selenium

Debomita Bhattacharjee
Updated on 01-Feb-2021 12:19:14

7K+ Views

We can verify if an element does not exist in Selenium webdriver. To achieve this, we shall use the method getPageSource which gets the entire page source. So we can obtain a complete page source and check if the text of the element exists.We also use the findElements method and utilize any locators like xpath, CSS, and so on to identify the matching elements. The findElements gives an elements list.We shall count the number of elements returned by the list with the help of the size method. If the value of size is greater than 0, then the element exists ... Read More

Find Amount of Water Wasted After Filling the Tank in C++

Hafeezul Kareem
Updated on 01-Feb-2021 12:18:23

340 Views

In this tutorial, we are going to solve the following problem.Given a tank with a capacity of N liters and a pump that fill the tank with S speed per minute. Unfortunately, there is a hole in the tank. And water is wasting at a speed of WS per minute while filling it.We need to calculate the amount of water wasted for a full tank.The amount of water filled per minute is equal to the difference between the water filling water and wasting water speed.Hence we can get the total time to fill the water tank by dividing the capacity ... Read More

Find All Pairs with Given Sum in a BST in C++

Hafeezul Kareem
Updated on 01-Feb-2021 12:18:07

425 Views

In this tutorial, we are going to write a program that finds all the pairs whose sum is equal to the given number in the binary search tree.We are going to store and values of trees in two different lists to find the pairs. Let's see the steps to solve the problem.Create a struct node for a binary tree.Write a function to insert a new node into the binary search tree.Remember, in the binary search tree all the elements that are less than root are smaller, and right are larger.Initialize two empty lists to store the left and right nodes ... Read More

Integrate Sikuli Scripts into Selenium

Debomita Bhattacharjee
Updated on 01-Feb-2021 12:17:42

2K+ Views

We can integrate Sikuli scripts into Selenium webdriver. Sikuli is an automation tool which is open-source. It has the feature to capture the images on the elements as well as perform operations on them.Some of the advantages of Sikuli are −Desktop or Windows applications can be automated.Can be used for flash testing.Can be used on platforms like mobile, Mac, and Linux.It is based on image recognition technique.Can be easily integrated with Selenium.To integrate Sikuli with Selenium, follow the below steps − Navigate to the link − https://launchpad.net/sikuli/+download.Click on the jar to download it (which can be used for Java environments) ... Read More

Select and Get Drop Down Option in Selenium

Debomita Bhattacharjee
Updated on 01-Feb-2021 12:15:15

915 Views

We can select the dropdown option in Selenium webdriver. The dropdowns can be worked upon with the help of the Select class. The select tag is used to represent a dropdown and option tag is used to represent items in the dropdown in html.Let us investigate the html structure of a dropdown −We have to add the statement − import org.openqa.selenium.support.ui.Select to use the Select class methods. The Select class methods are listed below −selectByIndex(n) − An option is chosen based on the index of the option on the dropdown. The index n is passed as a parameter to the ... Read More

Resolve Stale Element Reference Exception in Selenium WebDriver

Debomita Bhattacharjee
Updated on 01-Feb-2021 12:14:27

7K+ Views

We can resolve StaleElementReferenceException in Selenium webdriver. The term stale means something which is not fresh and decayed. Thus a stale element points to an element which is not present any more.There may be a case, when an element was in DOM initially but after modifications in Document Object Model (DOM), the element becomes stale and the StaleElementReferenceException is thrown if we make an attempt to access this element.This exception is caused whenever an element is not present in the DOM, or deleted. We can handle this exception by the following ways −Refreshing the page and verifying again.Implement retry method.ExampleCode ... Read More

Find All Divisors of a Natural Number in C++ - Set 2

Hafeezul Kareem
Updated on 01-Feb-2021 12:13:53

2K+ Views

In this tutorial, we are going to write a program that finds all the divisors of a natural number. It's a straightforward problem. Let's see the steps to solve it.Initialize the number.Write a loop that iterates from 1 to the square root of the given number.Check whether the given number is divisible by the current number or not.If the above condition satisfies, then print the current number and given_number/current_number.ExampleLet's see the code. Live Demo#include using namespace std; void findDivisors(int n) {    for (int i = 1; i

Find All Divisors of a Natural Number in C++

Hafeezul Kareem
Updated on 01-Feb-2021 12:10:48

6K+ Views

In this tutorial, we are going to write a program that finds all the divisors of a natural number. It's a straightforward problem. Let's see the steps to solve it.Initialize the number.Write a loop that iterates from 1 to the given number.Check whether the given number is divisible by the current number or not.If the above condition satisfies, then print the current number.ExampleLet's see the code. Live Demo#include using namespace std; void findDivisors(int n) {    for (int i = 1; i

Find All Triplets with Zero Sum in C++

Hafeezul Kareem
Updated on 01-Feb-2021 12:09:53

453 Views

In this tutorial, we are going to write a program that finds the triplet in the array whose sum is equal to the given number.Let's see the steps to solve the problem.Create the array with dummy data.Write three inner loops for three elements that iterate until the end of the array.Add the three elements.Compare the sum with 0.If both are equal, then print the elements and break the loops.ExampleLet's see the code. Live Demo#include using namespace std; void findTripletsWithSumZero(int arr[], int n){    bool is_found = false;    for (int i = 0; i < n-2; i++) {       ... Read More

Click on Hidden Element in Selenium WebDriver

Debomita Bhattacharjee
Updated on 01-Feb-2021 12:09:36

4K+ Views

We can click on the hidden element in Selenium webdriver. In DOM, the hidden elements are the ones which are not displayed on the page. CSS property style should have the value display:none set for the hidden elements. Also, if the hidden element resides within a form tag, it can be made hidden by setting the attribute type to hidden.ElementNotVisibleException is thrown by Selenium while handling hidden elements. So JavaScript Executors can be utilized to access and handle these elements. The executeScript method is used in Selenium to execute the JavaScript commands. The commands to be executed are passed as ... Read More

Advertisements