Java

Linux OpenJDK8 Installation (Since Oracle has Begun Its Final Chapter of Enslavement)

 

 

How to download and install prebuilt OpenJDK packages

JDK 9 & Later

Oracle's OpenJDK JDK binaries for Windows, macOS, and Linux are available on release-specific pages of jdk.java.net as .tar.gz or .zip archives.

As an example, the archives for JDK 11 may be found on jdk.java.net/11 and may be extracted on the command line using

$ tar xvf openjdk-11*_bin.tar.gz

or

$ unzip openjdk-11*_bin.zip

depending on the archive type.

Tags

Selenium: WebDriver Wait

ImplicitWait

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

FluentWait

  • creates a method that polls for a successful findElement() response every 5s - for 30s
  • wait.until(loop until no exception/false returned){
    • create an 'on-the-fly' method
      • create a FluentWait wait & set its properties
      • try findElement(By) while response is NoSuchElementFound or null
        • once true, return WebElement

requires import:

Tags

Ubuntu: Java JDK8 apt-get

  • https://tecadmin.net/install-oracle-java-8-ubuntu-via-ppa/

Java8 add repo, update, and install

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

 

Set Java8 as Default

sudo apt-get install oracle-java8-set-default

 

Check Java Version

java -version

java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b12, mixed mode)

 

Set JAVA_HOME & JDK_HOME

  • Seen this done through export, but so be it...
cat >> /etc/environment <<EOL
JAVA_HOME=/usr/lib/jvm/java-8-oracle
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
EOL

Java: Retrieving OS & Browser Versions with Selenium WebDriver

GetEnvInfo Class

  • Uses WebDriver to get the Browser type/version
  • Uses SystemProperty to get OS Type
package com.cs.cmsauto.utilities;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.RemoteWebDriver;

public class GetEnvInfo {
    private static WebDriver browserDriver;

    public static String getBrowserAndVersion() {
        String browser_version = null;
        Capabilities cap = ((RemoteWebDriver) browserDriver).getCapabilities();
        String browsername = cap.getBrowserName();
        // This block to find out IE Version number
        if ("internet explorer".equalsIgnoreCase(browsername)) {
            String uAgent = (String) ((JavascriptExecutor) browserDriver).executeScript("return navigator.userAgent;");
            System.out.println(uAgent);
            // uAgent return as "MSIE 8.0 Windows" for IE8
            if (u
Tags
Subscribe to Java