We can set the Selenium webdriver to get timeout. There are numerous methods to implement timeouts. They are listed below −setScriptTimeout.pageLoadTimeout.implicitlyWait.The setScriptTimeout is the method to set the time for the webdriver. This is usually applied for an asynchronous test to complete prior throwing an exception. The default value of timeout is 0.This method is generally used for JavaScript commands in Selenium. If we omit setting time for the script, the executeAsyncScript method can encounter failure due to the more time consumed by the JavaScript to complete execution.If the timeout time is set to negative, then the JavaScript can execute ... Read More
In this tutorial, we are going to write a program that finds the peak element in the given arrayThe peak element is an element that is greater than the surrounding elements. Let's see the steps to solve the problem.Initialize the array with dummy data.Check for the first element and last element for the peak element condition.Iterate over the array from the second element.Check whether the current element is greater than the previous element and the next element.Return if the above condition satisfies.Print the resultExampleLet's see the code. Live Demo#include using namespace std; int findPeakElement(int arr[], int n) { if ... Read More
In this tutorial, we are going to write a program that finds the peak element in the given linked list.The peak element is an element that is greater than the surrounding elements. Let's see the steps to solve the problem.Create a struct node for the linked list.Create the linked list with dummy data.Check for the base cases like whether the linked list is empty or of length 1.Store the first element in a variable called previous.Iterate over the linked list.Check whether the current element is greater than the previous element and the next element.Return if the above condition satisfies.Update the ... Read More
In this tutorial, we are going to write a program that finds the peak element in a 2D array.An element is called a peak element if all the elements around it are smaller than the element.Let's see the steps to solve the problem.Initialize the 2D array with dummy data.Iterate over the 2D array.First, check the corner elements of the 2D array.Next, write the conditions for the first and last rows of the 2D array.Now, check for the first and last columns of the 2D array.And finally, check the middle elements.In each case, we have to compare the current element with ... Read More
We can execute a JavaScript function in Python with Selenium webdriver. DOM interacts with the elements via JavaScript. Selenium is capable of executing JavaScript commands with the execute_script method.Few actions like web scrolling cannot be done by Selenium directly. For this, we shall use the JavaScript Executor. We shall take the help of the JavaScript command window.scrollTo and pass it to the execute_script method. To scroll to the bottom of the page, we have to pass 0 and document.body.scrollHeight as parameters to the window.scrollTo.Syntaxdriver.execute_script("window.scrollTo(0, document.body.scrollHeight);")Examplefrom selenium import webdriver driver = webdriver.Firefox(executable_path="C:\geckodriver.exe") driver.implicitly_wait(0.5) driver.get("https://www.tutorialspoint.com/index.htm") #scroll till page bottom driver.execute_script("window.scrollTo(0, document.body.scrollHeight);)We can ... Read More
We shall explore the prerequisites to learn Selenium. First of all, we should know that testing can be divided into two segments − Manual and Automation.For manual testing, it is essential to have the basic understanding of the application that we are going to test, a reasonable acumen and a good documentation skill.For automation testing, we should learn and develop skills on the basic testing along with automation testing concepts. Apart from these, we should have understanding on the below topicss −DatabaseProgramming logicData StructureFront End Development.Now let us see what major topics we should know under the basic testing concepts ... Read More
In this tutorial, we are going to find the partition point in an array where all the elements left to the partition point are small and all the elements right to the partition point are large.Let's see the steps to solve the problem.Initialize the array.Iterate over the array.Iterate from 0 to I and check each value whether it is smaller than the current value or not.Iterate from I to n and check each value whether it is larger than the current value or not.If the bot the conditions satisfied, then return the value.Print the partition point.ExampleLet's see the code. Live Demo#include ... Read More
In this tutorial, we are going to write a program that finds the pair 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 of ... Read More
In this tutorial, we are going to find a number whose some including with its digits is equal to the given number N.The idea is simple, we are going to check the left and right 100 numbers of the given number. It won't lie out that bound as N ≤ 1000000000 and the sum won't exceed 100.Let's see the steps to solve the problem.Initialize the number.Write a loop that iterates 100 times.Get the n - i and n + i values.Find the sum of the digits and add them.If anyone of them is equal to the N, print them.ExampleLet's see ... Read More
In this tutorial, we are going to find the number that is divided into maximum elements in the given array.Let's see the steps to solve the problem.Initialize the array and a variable to store the result.Iterate over the array.Initialize the counter variable.Iterate over the array again.Increment the counter if the current element is divisible by the array element.Update the result if the current count is maximum.Print the result.ExampleLet's see the code. Live Demo#include using namespace std; int numberWithMaximumMultiples(int arr[], int n) { int result = -1; for (int i = 0; i < n; i++) { ... Read More