This commit is contained in:
parent
09c9801fc9
commit
7ad5df5475
7
pom.xml
7
pom.xml
@ -15,6 +15,13 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<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>
|
||||
<groupId>com.aventstack</groupId>
|
||||
<artifactId>extentreports</artifactId>
|
||||
|
||||
31
src/main/java/zacksolutions/base/JokesAPI.java
Normal file
31
src/main/java/zacksolutions/base/JokesAPI.java
Normal file
@ -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.PageFactory;
|
||||
import zacksolutions.base.Initialization;
|
||||
import zacksolutions.base.JokesAPI;
|
||||
|
||||
public class HomePage extends Initialization {
|
||||
// Using PageFactory Object Model we get our elemets
|
||||
@ -23,8 +24,9 @@ public class HomePage extends Initialization {
|
||||
|
||||
// Actions
|
||||
public void insertText() throws InterruptedException {
|
||||
JokesAPI jokes = new JokesAPI();
|
||||
test = extent.createTest("Test msg");
|
||||
message.sendKeys("4 8 15 16 23 42");
|
||||
message.sendKeys(JokesAPI.setup + " ==> " + JokesAPI.punchline);
|
||||
button.click();
|
||||
extent.flush();
|
||||
}
|
||||
|
||||
@ -23,11 +23,13 @@ public class HomePageTest extends Initialization {
|
||||
|
||||
@Test
|
||||
public void TextTest() throws InterruptedException {
|
||||
// System.out.println(driver.getTitle());
|
||||
System.out.println(driver.getTitle());
|
||||
/*
|
||||
HomePage hp = new HomePage();
|
||||
hp.insertText();
|
||||
hp.textConfirmation();
|
||||
Assert.assertEquals(hp.textConfirmation(), "4 8 15 16 23 42");
|
||||
*/
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
|
||||
Loading…
Reference in New Issue
Block a user