Open Browser Window in Full Screen Using Selenium WebDriver

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:13:21

2K+ Views

We can open a browser window in full screen using Selenium webdriver in C# by using the method Maximize. This method has to be applied on the webdriver object.Syntaxdriver.Manage().Window.Maximize();Exampleusing NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System; namespace NUnitTestProject1{    public class Tests{       String url = "https://www.google.com/";       IWebDriver driver;       [SetUp]       public void Setup(){          //object of FirefoxDriver          driver = new FirefoxDriver();       }       [Test]       public void Test1(){          //URL launch          driver.Navigate().GoToUrl(url);          //browser maximize          driver.Manage().Window.Maximize();          Console.WriteLine("Browser Maximized");       }       [TearDown]       public void closeBrowser(){          driver.Quit();       }    } }Output

Select Item from Sub Menu Using Mouse Over Action in Selenium

Debomita Bhattacharjee
Updated on 07-Apr-2021 08:09:29

7K+ Views

We can select an item from the sub-menu of a menu using mouse over action in Selenium webdriver with the help of the Actions class. We shall create an object of the Actions class and then apply moveToElement to it.This method shall move the mouse to the middle of the menu which displays submenu on mouse over. Then apply the perform method to actually perform this action. After hovering on the menu, we shall select a sub-menu with the help of the click method.SyntaxWebElement n=driver.findElement(By.id("nav-link-accountList")); Actions a = new Actions(driver); a.moveToElement(n).perform();Let us hover on the below highlighted menu on the ... Read More

Length of Longest String Chain in JavaScript

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

365 Views

Word ChainLet's say word1 is a predecessor of word2 if and only if we can add exactly one letter anywhere in word1 to make it equal to word2. For example, "abc" is a predecessor of "abac".A word chain is a sequence of words [word_1, word_2, ..., word_k] with k >= 1, where word_1 is a predecessor of word_2, word_2 is a predecessor of word_3, and so on.ProblemWe are required to write a JavaScript function that takes in an array of strings, arr, as the first and the only argument.Each string in the array arr consists of English lowercase letters. Our ... Read More

Rearranging Array Elements in JavaScript

AmitDiwan
Updated on 07-Apr-2021 07:57:44

184 Views

ProblemJavaScript function that takes in an array of literals, arr, as the first and the only argument. This array contains some duplicates placed adjacently.Our function should rearrange the elements of the array such that no two elements in the array are equal. Our function should return the rearranged array, given that it's guaranteed that there exists at least one possible way of such arrangement.For example, if the input to the function is −const arr = [7, 7, 7, 8, 8, 8];Then the output should be −const output = [7, 8, 7, 8, 7, 8];Output Explanation:There may be other correct possible ... Read More

Finding Sequential Digit Numbers Within a Range in JavaScript

AmitDiwan
Updated on 07-Apr-2021 07:49:20

395 Views

Sequential Digits NumberA number has sequential digits if and only if each digit in the number is one more than the previous digit.ProblemWe are required to write a JavaScript function that takes in an array, arr, of exactly two elements specifying a range.Our function should return a sorted array of all the integers in the range arr (limits inclusive) that have sequential digits.For example, if the input to the function is −const arr = [1000, 13000];Then the output should be −const output = [1234, 2345, 3456, 4567, 5678, 6789, 12345];ExampleThe code for this will be − Live Democonst arr = [1000, ... Read More

Distributing Bananas Problem in JavaScript

AmitDiwan
Updated on 07-Apr-2021 07:47:11

342 Views

ProblemSuppose there are n people standing in a queue, we wish to distribute bananas to the people in the following way −We give 1 banana to the first person, 2 bananas to the second person, and so on until we give n bananas to the last person.Then, we go back to the start of the row, giving n + 1 bananas to the first person, n + 2 bananas to the second person, and so on until we give 2 * n bananas to the last person.This process repeats (with us giving one more banana each time, and moving to ... Read More

Path with Smallest Sum in JavaScript

AmitDiwan
Updated on 07-Apr-2021 07:26:18

281 Views

ProblemJavaScript function that takes in a 2-D array of numbers as the first and the only argument.Our function should find paths from the 2-D array by picking exactly one element from each row, and no two elements picked from adjacent rows should be in the same column. Out of all these paths, our function should return the sum of that path that has the minimum sum.For example, if the input to the function is −const arr = [    [4, 7, 1],    [2, 8, 3],    [5, 6, 9] ]Then the output should be −const output = 9;Output ExplanationBecause ... Read More

Alternative of Click in Selenium

Debomita Bhattacharjee
Updated on 06-Apr-2021 11:58:14

6K+ Views

There are several alternatives to the usage of click method in Selenium webdriver. We can use the JavaScript Executor to perform a click action. Selenium can execute JavaScript commands with the help of the executeScript method.The parameters – arguments[0].click() and locator of the element on which the click is to be performed are passed to this method.SyntaxWebElement n=driver.findElement(By.linkText("Refund")); JavascriptExecutor j = (JavascriptExecutor) driver; j.executeScript("arguments[0].click();", n);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; import org.openqa.selenium.JavascriptExecutor; public class JsClickLink{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); ... Read More

Google Search Automation with Python Selenium

Debomita Bhattacharjee
Updated on 06-Apr-2021 11:57:39

7K+ Views

We can perform Google search automation with Selenium webdriver in Python. First of all, we shall locate the Google search box with the help of any of the locators like id, css, xpath, class, or name.Then simulate the action of pressing the ENTER key with the help of Keys.ENTER/Keys.RETURN. To perform this operation, we have to use the method send_keys and then pass the parameter – Keys.RETURN /Keys.ENTER. Also, we have to add the statement - from selenium.webdriver.common.keys import Keys to use the Keys class.Examplefrom selenium import webdriver from selenium.webdriver.common.keys import Keys import time #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") ... Read More

What is Following Sibling in Selenium

Debomita Bhattacharjee
Updated on 06-Apr-2021 11:57:08

25K+ Views

We can use the concept of following-sibling in xpath for identifying elements in Selenium. It identifies the siblings of the context node. The siblings should be located at the equal level of the existing node and should have the same parent.Let us see an example of an element with ul tag having more than one child with li tag. Then let us try to locate the fifth li element (Effective Resume Writing) from the first li element with class attribute sreading.Syntax//li[@class='sreading']/following-sibling::li[4]Here, we are locating the fifth child of ul tag, but we have provided li[4] since we are locating the ... Read More

Advertisements