Verify If an Element is Displayed on Screen in Selenium

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:07:49

9K+ Views

We can verify the visibility of web elements like edit box, checkbox, radio buttons and so on with the help of method listed bels −isDisplayed()This method checks if a webelement is present on the screen.Syntax −Boolean result = driver.findElement(By.xpath("//span[text()=’Coding Ground’]")).isDispayed();isSelected()This method checks the status of the radio button, check box and options in the static dropdown.Syntax −Boolean btnresult = driver.findElement(By.xpath("//xpath[contains(@class, ’gsc-search-button’)]")).isSelected();isEnabled()Syntax −Boolean btnresult = driver.findElement(By.xpath("//xpath[contains(@class, ’gsc-search-button’)]")).isEnabled();This method if an element is enabled or not.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 ElementStatus{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       ... Read More

Sum of Square Numbers in C++

Arnab Chakraborty
Updated on 11-Jun-2020 12:05:53

1K+ Views

Suppose we have a non-negative integer c, we have to decide whether there're two integers a and b such that it satisfies a^2 + b^2 = c.So, if the input is like 61, then the output will be True, as 61 = 5^2 + 6^2.To solve this, we will follow these steps −Define a function isPerfect(), this will take x, sr := square root of xreturn true when (sr - floor of sr) is 0From the main method do the following, if c is same as 0, then −return truefor initialize i := 0, when i < the ceiling of ... Read More

Deal with Reusable Components in Selenium Java

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:05:37

1K+ Views

We can deal with reusable components in Selenium Java with the help of inheritance concept. It is a parent child relationship where the child class inherits the properties and methods of the parent class.ExampleFor Parent class.import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class Baseclass {    public void login() throws IOException {       Properties prop = new Properties();       //Reading values from property file       FileInputStream ips = new FileInputStream(       "C:\Users\ghs6kor\eclipse- workspace\Inheritance\config.properties");       prop.load(ips);       System.setProperty("webdriver.gecko.driver",       ... Read More

Maximum Product of Three Numbers in C++

Arnab Chakraborty
Updated on 11-Jun-2020 12:04:32

831 Views

Suppose we have an integer array; we have to find three numbers whose product is maximum then return the maximum product.So, if the input is like [1, 1, 2, 3, 3], then the output will be 18, as the three elements are [2, 3, 3].To solve this, we will follow these steps −sort the array numsl := size of numsa := nums[l - 1], b := nums[l - 2], c := nums[l - 3], d := nums[0], e := nums[1]return maximum of a * b * c and d * e * aExample Let us see the following implementation to get ... Read More

Can Place Flowers in C++

Arnab Chakraborty
Updated on 11-Jun-2020 12:03:16

1K+ Views

Suppose we have a long flowerbed in which some of the plots are planted and some are empty. Now there is a constraint, flowers cannot be planted in adjacent plots, they would compete for water and both would die. So if we have a flowerbed, represented by an array containing 0 and 1, 0 indicates empty and 1 indicates fill, and a number n is also given, we have to check whether n new flowers can be planted in it without violating the no-adjacent-flowers rule or not.So, if the input is like flowerbed = [1, 0, 0, 0, 1], n ... Read More

Handle Proxy in Selenium with Java

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:02:55

2K+ Views

We can handle proxy in Selenium in Java with the help of PROXY class.import java.io.IOException; import org.openqa.selenium.Proxy; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; public class ProxySelJav {    public static void main(String[] args) {       // TODO Auto-generated method stub       WebDriver driver;       String prox = "localhost:8080";       // set browser settings with Desired Capabilities       Proxy p = new Proxy(); p.setHttpProxy(prox).setFtpProxy(prox).setSslProxy(prox)       .setSocksProxy(prox);       DesiredCapabilities c = new DesiredCapabilities();       c.setCapability(CapabilityType.PROXY, p);       // utilize capabilities on launching ... Read More

Take Care of SSL Certificate Issues in Chrome Browser Using Selenium

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:01:15

670 Views

We can face SSL certificate issue because of the reasons listed below −While the website was developed, its SSL certificate was not proper.The site may have a self-signed certificate.SSL not configured properly at the server level.Exampleimport org.openqa.selenium.Capabilities; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; public class SSLCert {    public static void main(String[] args) {       // TODO Auto-generated method stub       //Desired capabilities for general chrome profile       DesiredCapabilities c=DesiredCapabilities.chrome();       c.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);       c.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);       //ChromeOptions for local browser       ... Read More

Minimum Index Sum of Two Lists in C++

Arnab Chakraborty
Updated on 11-Jun-2020 12:00:29

218 Views

Suppose there are two fiends Amal and Bimal want to choose a restaurant for dinner, now they both have a list of favorite restaurants represented by strings. We have to help them to find out their common interest with the least list index sum. If there is a choice tie between different answers, then return all of them with no order requirement.So, if the input is like ["ABC", "PQR", "MNO", "XYZ"], and ["TUV", "GHI", "KLM", "ABC"], then the output will be ["ABC"]To solve this, we will follow these steps −Define one map mpleast := inffor initialize i := 0, when ... Read More

Use Properties File to Declare Global Variables in Selenium Framework

Debomita Bhattacharjee
Updated on 11-Jun-2020 11:59:39

2K+ Views

We can declare global variables in Selenium with the help of the Properties class which works with .properties file. In the .properties file, the data is stored in key value pairs. We can read and write values in the .properties file.Eaxmpleimport java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class Propert {    public static void main(String[] args) throws IOException {       // TODO Auto-generated method stub       Propert t = new Propert();       t.login();    }    public void login() throws IOException {       Properties ... Read More

Range Addition II in C++

Arnab Chakraborty
Updated on 11-Jun-2020 11:59:08

252 Views

Suppose we have one m * n matrix called M and this is initialized with all 0's and we also have several update operations. Now, operations are represented by a 2D array, and each operation is represented by an array with two positive integers x and y, it means M[i][j] should be added by one for all values i in range 0 to a - 1 and all values j in range 0 to b - 1. We have to find the count of the number of maximum integer in the matrix after performing all the operations.So, if the input ... Read More

Advertisements