Make Android Device Vibrate Programmatically Using Kotlin

Azhar
Updated on 30-Nov-2020 11:40:34

2K+ Views

This example demonstrates how to make an Android device vibrate programmatically using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.content.Context import android.os.Build import android.os.Bundle import android.os.VibrationEffect import android.os.Vibrator import androidx.appcompat.app.AppCompatActivity @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       ... Read More

Find Selenium WebDriver Release Notes

Debomita Bhattacharjee
Updated on 30-Nov-2020 11:02:41

128 Views

We can find the release notes of Selenium webdriver. They reside within the source control under the specific folder for the particular language libraries. Follow the steps one by one −Navigate to the link − http://docs.seleniumhq.org/.Click on the Download tab.Move to the Selenium Client & WebDriver Language Binding section.Click on the Change Log link for each of the languages.

Pause Selenium for X Seconds

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:58:55

2K+ Views

We can get Selenium to pause for X seconds with the concept of synchronization. There are two types of waits − implicit and explicit. Apart from this there is the Thread.sleep method that halts Selenium for a certain time. The wait time is passed as an argument to the method.ExampleCode Implementation with Thread.sleep.import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class ThreadWt{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       driver.get("https://www.tutorialspoint.com/index.htm");       // identify element, enter text     ... Read More

Use of clickAt Selenium Command

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:58:01

3K+ Views

We can use the ClickAt command in Selenium IDE. The ClickAt command has two arguments − the element locator and the coordinates which mentions the x and y coordinates of the mouse with respect to the element identified by the locator.This method is used when we want to click on a position having a specific mouse coordinate. It can click on a checkbox, radio button or link.SyntaxclickAt(locator, coordinates)In the Selenium IDE, Choose a row inside the test script edit box. Enter click at the Command field. To identify the dropdown with the id locator, enter the Target field. The x ... Read More

Scroll Down Using Selenium WebDriver with Java

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:55:10

2K+ Views

We can scroll down with Selenium. Selenium is unable to handle scrolling directly. It takes the help of the Javascript Executor to perform the scrolling action up to an element.First of all we have to locate the element up to which we have to scroll to. Next, we shall use the Javascript Executor to run the Javascript commands. The method executeScript is used to run Javascript commands in Selenium. We shall take the help of the scrollIntoView method in Javascript and pass true as an argument to the method.SyntaxWebElement elm = driver.findElement(By.name("name")); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", elm);Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; ... Read More

Set Google Chrome in WebDriver

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:52:39

628 Views

We can set Google Chrome in Selenium. Java JDK, Eclipse and Selenium webdriver should be configured in the system before setting up the Chrome browser.Steps to set Google Chrome are −Navigate to the link: https://chromedriver.chromium.org/downloads.Select the Chrome driver link which matches with the Chrome browser in the local system.Then, we have to select the Chrome driver link which is compatible with the operating system we are using.A zip file gets downloaded. Extract and save the chromedriver.exe file in a location.We can configure the chromedriver.exe file in the following ways −By setting the System Properties in the Environment Variables. Go to ... Read More

Simulate Print Screen Button Using Selenium WebDriver in Java

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:50:15

517 Views

We can simulate a Print screen button with Selenium. The screenshot is captured with the Print screen button. Capturing a screenshot is a three way process. It is an important step towards failure analysis.We shall convert the driver object to TakeScreenshot interface.SyntaxTakesScreenshot s = (TakesScreenshot)driver;Then, with the getScreenshotAs method we shall have an image file and copy that file to a location with FileUtils.copyFile method.SyntaxFile sp=s.getScreenshotAs(OutputType.FILE); FileUtils.copyFile(sp, new File("path of image file"));Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.apache.commons.io.FileUtils; import java.io.File; public class PrintScreenSimulate {    public static void main(String[] args) {     ... Read More

Clear Browser Cookies with Selenium WebDriver Java Bindings

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:49:08

698 Views

We can clear browser cookies in Selenium. The method deleteCookieNamed shall delete a cookie with a specific name. The cookie named is passed as an argument to the method. First, we will add a cookie, then get it and finally delete it.Syntaxdriver.manage().deleteCookieNamed("foo");Another method called the deleteAllCookies deletes all cookies from the existing domain. First, we will add the cookies, then get and delete them.Syntaxdriver.manage().deleteAllCookies();Exampleimport java.util.Set; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class DeleteCookiesViaName{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();   ... Read More

Delete Cookies on All Domains Using Selenium WebDriver

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:46:54

3K+ Views

We can delete cookies on all domains with Selenium. The method deleteAllCookies is used to delete all cookies from the present domain. First, we shall add cookies, then get them and finally delete all the cookies.Syntaxdriver.manage().deleteAllCookies();Exampleimport java.util.Set; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class DeleteCookies{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       driver.get("https://www.tutorialspoint.com/index.htm");       // wait of 4 seconds       driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);       // setting name and value for cookie     ... Read More

Install Selenium in a Conda Environment

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:45:28

997 Views

We can install Selenium in a conda environment. The conda has multiple channels to find packages. We have to search for a package which is compatible with our operating system.All the packages shall be available in the link −https://anaconda.org/search?q=selenium&sort=ndownloads&sort_order=−1&reverse=trueOut of all the packages, the most popular and downloaded one is available in the link −https://anaconda.org/conda-forge/seleniumTo install this package, execute any one of the following commands −

Advertisements