@@ -15,6 +15,13 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.18.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aventstack</groupId>
|
<groupId>com.aventstack</groupId>
|
||||||
<artifactId>extentreports</artifactId>
|
<artifactId>extentreports</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package zacksolutions.base;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JokesAPI
|
||||||
|
*/
|
||||||
|
public class JokesAPI {
|
||||||
|
|
||||||
|
public static String setup;
|
||||||
|
public static String punchline;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
|
||||||
|
URL apiUrl = new URL("https://official-joke-api.appspot.com/jokes/random");
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
|
||||||
|
connection.setRequestProperty("accept", "application/json");
|
||||||
|
InputStream responseStream = connection.getInputStream();
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
JsonNode root = mapper.readTree(responseStream);
|
||||||
|
setup = root.path("setup").asText();
|
||||||
|
punchline = root.path("punchline").asText();
|
||||||
|
System.out.println(setup + " --> " + punchline);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import org.openqa.selenium.WebElement;
|
|||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
import zacksolutions.base.Initialization;
|
import zacksolutions.base.Initialization;
|
||||||
|
import zacksolutions.base.JokesAPI;
|
||||||
|
|
||||||
public class HomePage extends Initialization {
|
public class HomePage extends Initialization {
|
||||||
// Using PageFactory Object Model we get our elemets
|
// Using PageFactory Object Model we get our elemets
|
||||||
@@ -23,8 +24,9 @@ public class HomePage extends Initialization {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
public void insertText() throws InterruptedException {
|
public void insertText() throws InterruptedException {
|
||||||
|
JokesAPI jokes = new JokesAPI();
|
||||||
test = extent.createTest("Test msg");
|
test = extent.createTest("Test msg");
|
||||||
message.sendKeys("4 8 15 16 23 42");
|
message.sendKeys(JokesAPI.setup + " ==> " + JokesAPI.punchline);
|
||||||
button.click();
|
button.click();
|
||||||
extent.flush();
|
extent.flush();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ public class HomePageTest extends Initialization {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void TextTest() throws InterruptedException {
|
public void TextTest() throws InterruptedException {
|
||||||
// System.out.println(driver.getTitle());
|
System.out.println(driver.getTitle());
|
||||||
|
/*
|
||||||
HomePage hp = new HomePage();
|
HomePage hp = new HomePage();
|
||||||
hp.insertText();
|
hp.insertText();
|
||||||
hp.textConfirmation();
|
hp.textConfirmation();
|
||||||
Assert.assertEquals(hp.textConfirmation(), "4 8 15 16 23 42");
|
Assert.assertEquals(hp.textConfirmation(), "4 8 15 16 23 42");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterTest
|
@AfterTest
|
||||||
|
|||||||
Reference in New Issue
Block a user