Posts

Showing posts from October, 2018

Running ChromDriver on linux / unix Operating System using Jav

1. Download ChromeDriver for the linux environment 2. create a folder "drivers" on project folder 3. put the chromedriver file on the drivers folders 4. on the project class file copy the below script System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");   Map prefs = new HashMap ();         prefs.put("profile.default_zoom_level",  -0.15); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--headless"); chromeOptions.addArguments("--no-sandbox"); chromeOptions.addArguments("window-size=1920x1080"); // used to show webpage in standard window size driver = new ChromeDriver(chromeOptions); 5. Imports import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Properties; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions...

Running ChromeDriver on iMac or iOS

1. create a folder called "drivers"  on project folder 2. Download ChromeDriver latest version web and put it inside the drivers folder 3. On project class file copy below script DesiredCapabilities capabilities = new DesiredCapabilities(); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--start-maximized"); capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions); chromeOptions.setHeadless(true); System.out.println(System.getProperty("user.dir")); System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/drivers/chromedriver"); WebDriver driver = new ChromeDriver(); 4. Imports of above script import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.DesiredCapabilities;

How to send Slack Message using JAVA

1. Get URL from admin who look after Slack. ASk him to create a hook and give the URL String url = "https://hooks.slack.com/services/starts like tis but it has some alphanumericoverlength"; 2. Create a channel on your slack where you login succesfully. you should belong to same group as hooks created by admin String channelName = "#channel"; 3. Below is the code to send slack message Payload payload = Payload.builder().channel(channelName).username("Test Automation Results") .iconEmoji(":robot_face:") .text("Hi, Please find the Test Automation Results after Deployment Run.   Kind Regards  \n Test Automation Team") .build(); Slack slack = Slack.getInstance(); WebhookResponse response = slack.send(url, payload);

How to Upload a file to S3 Bucket on AWS using JAVA

This is the simple method to upload a file in S3 Bucket. It could be public or private 1. pom.xml dependency go to mvnrepository website and search for "aws-java-sdk-s3". Find version 1.11.424 and copy pom dependency and put it on pom.xml file                 com.amazonaws aws-java-sdk-s3 1.11.424 2. these are the imported from dependency jars to make sure you have not choose wrong one in case Imports: import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.AWSStaticCredentialsProvider; import com.amazonaws.regions.Regions; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3ClientBuilder; 3. Details Required Please ask administrator responsible for AWS. ask for accessKey and SecretKey Ask for S3 Bucket folder if not ask him to create a S3 Bucket folder where you can upload the file 4. Java Code to upload file on to S3 Bucket UploadToS3Bucket uploadToAWS = new Uploa...