We can hold a key down with Selenium webdriver. We mostly utilize the CONTROL/SHIFT/ALT keys to hold down and then click on other keys. So, only mentioning the modifier keys like keys.CONTROL/ keys.SHIFT or Keys.ALT is not sufficient.To hold down a key simultaneously while another key is being pressed, we use the keyDown() and keyUp() methods. Both these methods accept the modifier key as a parameter.The action of these two methods on a key yields a special functionality of a key. All these methods are a part of Actions class in Selenium. We have to add the import org.openqa.selenium.interactions.Actions package ... Read More
We can perform key press of (CTRL+A) with Selenium Webdriver. There are multiple ways to do this. We can use the Keys.chord() method to simulate this keyboard action.The Keys.chord() method helps to press multiple keys simultaneously. It accepts the sequence of keys or strings as a parameter to the method. To press CTRL+A, it takes, Keys.CONTROL, "a" as parameters.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 PressCtrlA{ 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"; ... Read More
We can find elements inside form and iframe with Selenium webdriver. A form in an html document is represented by atag. A form may contain multiple elements inside it. A form can be submitted with a submit() or a click() method.Let us see a form with fields email and password.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class FormElements{ 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.linkedin.com/"; driver.get(url); driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS); // ... Read More
We can perform right click using Selenium ChromeDriver. On right clicking on a webelement, the context menu gets displayed. For example, if we right click on a text area, an additional menu with several options come up.Actions class in Selenium is responsible for simulating this mouse operation. The Actions class provides the contextClick() method to carry out this action and select any option from the context menu.To perform this entire operation, we shall first move the mouse to the middle of the element with moveToElement() method, then apply contextClick() method. Furthermore, we have to execute the build() method to execute the ... Read More
In this problem, we are given a string num which is a large number. Our task is to create a program to find remainder when large number is divided by 11 in C++.Problem Description − We need to find the remainder when the number defined by the string is divided by 11.Let’s take an example to understand the problemInputnum = “43212981843718452”Output7Solution ApproachTo find the remainder, we obviously need to divide the number. But dividing huge number is a complex process so to ease up the process, we will divide digit by digit. And store the remainder that follows. This process ... Read More
In this problem, we are given a string num which is a large number and an integer R. Our task is to create a program to find remainder when large number is divided by r in C++.Problem Description − We need to find the remainder when the number defined by the string is divided by r which is a two-digit number.Let’s take an example to understand the problemInputnum = “123423450942121” r = 54Output7Solution ApproachTo find the remainder, we obviously need to divide the number. But dividing huge numbers is a complex process so to ease up the process, we will ... Read More
In this problem, we are given two numbers, N and D. Our task is to create a Program to find remainder without using modulo or % operator in C++.Problem description − We need to find the remainder that will be left after dividing the number N by D. But we cannot use the modulo or % operator for this.Let’s take an example to understand the problemInputN = 53 D = 3Output2Solution ApproachTo find the remainder, a simple approach is to find the number less than N which is the multiple of D. And the substrate the number from N. To ... Read More
In this problem, we are given string str. Our task is to create a Program to find second most frequent character in C++.Let’s take an example to understand the problemInputstr = “abaacabcba”Output‘b’Solution ApproachTo find the character that is second most frequent in the string. We need to maintain a count array chatCount that is used to store the frequency of each character in the string. And then using the array we will find the character with max and secondMax frequency in the array. And display the second most frequent character.Program to illustrate the working of our solutionExample Live Demo#include #include ... Read More
In this problem, we are given a doubly linked list. Our task is to create a program to find size of Doubly Linked List in C++.Doubly Linked List is a special type of Linked list in which navigation is possible in both ways, either forward and backward easily as compared to Single Linked List. The following are the important terms to understand the concept of doubly linked lists.Link − Each link of a linked list can store a data called an element.Next − Each link of a linked list contains a link to the next link called Next.Prev − Each ... Read More
In this problem, we are given string str. Our task is to create a program to find Smallest and Largest Word in a String in C++.Problem Description − Here, we have a string we need to find the word whose length is maximum and minimum out of all words in the string. The word is separated using white spaces or null(\0) characters.Let’s take an example to understand the problemInputstr = “Learn Programming at TutorialsPoint”Outputsmallest word = at largest word = TutorialspointSolution ApproachTo find the smallest and largest word, we will find the length of each word by using two indexes, ... Read More