Skip to content

Instantly share code, notes, and snippets.

@hidepin
Created March 17, 2016 21:08
Show Gist options
  • Save hidepin/93049154f92586d42367 to your computer and use it in GitHub Desktop.
Save hidepin/93049154f92586d42367 to your computer and use it in GitHub Desktop.
selenium_addon
package org.func.sample.selnium;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class Selenium {
public static void main(String[] args) {
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
FirefoxProfile profile = new FirefoxProfile();
RemoteWebDriver remoteWD = null;
int sleeptime = 2000;
try {
profile.addExtension(new File("C:/work/firebug-2.0.14.xpi"));
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
remoteWD = new RemoteWebDriver(new URL("http://192.168.137.225:4444/wd/hub"), capabilities);
// remoteWD.get("file://C:/selenium/Chapter 3/HTML/Frames.html");
remoteWD.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
remoteWD.navigate().to("https://www.google.co.jp");
WebElement searchBox = remoteWD.findElement(By.name("q"));
searchBox.sendKeys("Selenium WebDriver");
WebElement searchButton = remoteWD.findElement(By.name("btnK"));
searchButton.click();
Thread.sleep(sleeptime);
searchBox.clear();
Thread.sleep(sleeptime);
searchBox.sendKeys("Packt Publishing");
searchButton = remoteWD.findElement(By.name("btnG"));
searchButton.click();
Thread.sleep(sleeptime);
remoteWD.navigate().back();
Thread.sleep(sleeptime);
remoteWD.navigate().forward();
Thread.sleep(sleeptime);
remoteWD.navigate().refresh();
WebDriver augmentedDriver = new Augmenter().augment(remoteWD);
File screenshot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new File("C:/work/test.png"));
Thread.sleep(sleeptime);
remoteWD.quit();
} catch (InterruptedException | IOException e) {
e.printStackTrace();
}
}
}
@Cyber-Lord
Copy link

PLEASE WILL YOU HELP ME DO THIS FOR ME? AM A 100LEVEL STUDENT IN THE UNIVERSITY

Assignment 5

Create an applet containing three concentric triangles and another set of three concentric circles.  The three different triangles and circles should have different colors.
On the same applet view create a human-like figure with a circle, straight line and diagonal lines. The center (x,y coordinate) of the circle representing the human-like figure's head should be defined and clearly stated in a comment section of your code near the code for representing the human-like figure.
Each of the three figures should lie in three different rectangles/squares of the same size, with a fourth rectangle/square of same size left blank for balance; this means that there are going to be two rectangles/squares at the top of the applet  and two other rectangles/squares beneath the first two rectangles.
You are expected to upload two files a .java file, and a .html file. Zipped files will not be marked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment