Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 240b146

Browse files
committed
Stubs: fetch source code
1 parent 55beacc commit 240b146

File tree

5 files changed

+77
-21
lines changed

5 files changed

+77
-21
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@
33

44
# Ignore Gradle build output directory
55
build
6+
7+
*.log
8+
.vscode/
9+
bin/
10+
data/

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ dependencies {
2121

2222
// This dependency is used by the application.
2323
implementation libs.guava
24+
25+
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
26+
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.20.0'
2427
}
2528

2629
// Apply a specific Java toolchain to ease working on different environments.

app/src/main/java/xleetcode/App.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
/*
2-
* This Java source file was generated by the Gradle 'init' task.
3-
*/
41
package xleetcode;
52

63
public class App {
7-
public String getGreeting() {
8-
return "Hello World!";
4+
public void getGreeting() throws InterruptedException {
5+
// Removes unnecessary warnings from console
6+
System.setProperty("java.util.logging.config.file", "logging.properties");
7+
8+
TestCases tests = new TestCases(); // Initialize your test class
9+
10+
// TODO: call your test case functions one after other here
11+
// START Tests
12+
tests.testCase01();
13+
14+
// END Tests
15+
tests.endTest(); // End your test by clearing connections and closing browser
916
}
1017

11-
public static void main(String[] args) {
12-
System.out.println(new App().getGreeting());
18+
public static void main(String[] args) throws InterruptedException {
19+
new App().getGreeting();
1320
}
1421
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package xleetcode;
2+
3+
import java.io.File;
4+
import java.time.Duration;
5+
import java.util.logging.Level;
6+
7+
import org.openqa.selenium.WebDriver;
8+
import org.openqa.selenium.chrome.ChromeDriver;
9+
import org.openqa.selenium.chrome.ChromeDriverService;
10+
import org.openqa.selenium.chrome.ChromeOptions;
11+
import org.openqa.selenium.logging.LogType;
12+
import org.openqa.selenium.logging.LoggingPreferences;
13+
14+
public class TestCases {
15+
WebDriver driver;
16+
17+
public TestCases() {
18+
System.out.println("Constructor: TestCases");
19+
System.out.println("Start Tests: TestCases");
20+
21+
ChromeOptions options = new ChromeOptions();
22+
LoggingPreferences logs = new LoggingPreferences();
23+
24+
// Set log level and type
25+
logs.enable(LogType.BROWSER, Level.ALL);
26+
logs.enable(LogType.DRIVER, Level.ALL);
27+
options.setCapability("goog:loggingPrefs", logs);
28+
options.addArguments("start-maximized");
29+
options.addArguments("--disable-blink-features=AutomationControlled");
30+
31+
// Set path for log file
32+
File theDir = new File("logs");
33+
if (!theDir.exists()) {
34+
theDir.mkdirs();
35+
}
36+
System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, "logs" + File.separator + "chromedriver.log");
37+
38+
driver = new ChromeDriver(options);
39+
40+
// Implicit wait
41+
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
42+
}
43+
44+
public void endTest() {
45+
System.out.println("End Tests: TestCases");
46+
driver.quit();
47+
}
48+
49+
public void testCase01() throws InterruptedException {
50+
System.out.println("\nTestCase01: START");
51+
driver.get("https://www.google.com");
52+
Thread.sleep(5000);
53+
System.out.println("TestCase01: END\n");
54+
}
55+
}

app/src/test/java/xleetcode/AppTest.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)