fix: 21 finally fix with getter methods
All checks were successful
jenkins/ZenProject/pipeline/head This commit looks good

This commit is contained in:
dadgam3er 2024-10-01 22:23:12 -04:00
parent 4a5405049c
commit ed9847864a
4 changed files with 28 additions and 17 deletions

View File

@ -35,7 +35,7 @@
<a href="#"><span class="badge badge-primary">Zenful</span></a>
</li>
<li class="m-r-10">
<a href="#"><span class="badge badge-primary">Oct 1, 2024 09:45:03 PM</span></a>
<a href="#"><span class="badge badge-primary">Oct 1, 2024 10:20:06 PM</span></a>
</li>
</ul>
</div>
@ -81,7 +81,7 @@
<div class="test-detail">
<p class="name">Test msg</p>
<p class="text-sm">
<span>9:45:05 PM</span> / <span>00:00:00:000</span>
<span>10:20:29 PM</span> / <span>00:00:00:000</span>
<span class="badge pass-bg log float-right">Pass</span>
</p>
</div>
@ -90,8 +90,8 @@
<div class="p-v-10">
<div class="info">
<h5 class="test-status text-pass">Test msg</h5>
<span class='badge badge-success'>10.01.2024 9:45:05 PM</span>
<span class='badge badge-danger'>10.01.2024 9:45:05 PM</span>
<span class='badge badge-success'>10.01.2024 10:20:29 PM</span>
<span class='badge badge-danger'>10.01.2024 10:20:29 PM</span>
<span class='badge badge-default'>00:00:00:000</span>
&middot; <span class='uri-anchor badge badge-default'>#test-id=1</span>
<span title='Skip to the next failed step' class='badge badge-danger pointer float-right ne ml-1'><i class="fa fa-fast-forward"></i></span>
@ -115,13 +115,13 @@
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Started</p>
<h3>Oct 1, 2024 09:45:03 PM</h3>
<h3>Oct 1, 2024 10:20:06 PM</h3>
</div></div>
</div>
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Ended</p>
<h3>Oct 1, 2024 09:45:06 PM</h3>
<h3>Oct 1, 2024 10:20:29 PM</h3>
</div></div>
</div>
<div class="col-md-3">

View File

@ -13,10 +13,10 @@ import java.net.URL;
*/
public class JokesAPI {
public static String setup;
public static String punchline;
private String setup;
private String punchline;
public static void main(String[] args) throws IOException {
public void fetchJokes() throws IOException {
URL apiUrl = new URL("https://official-joke-api.appspot.com/jokes/random");
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
@ -24,8 +24,13 @@ public class JokesAPI {
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);
this.setup = root.path("setup").asText();
this.punchline = root.path("punchline").asText();
}
public String getSetup(){
return setup;
}
public String getPunchline(){
return punchline;
}
}

View File

@ -6,8 +6,7 @@ import org.openqa.selenium.support.PageFactory;
import zacksolutions.base.Initialization;
import zacksolutions.base.JokesAPI;
import static zacksolutions.base.JokesAPI.punchline;
import static zacksolutions.base.JokesAPI.setup;
import java.io.IOException;
public class HomePage extends Initialization {
// Using PageFactory Object Model we get our elemets
@ -20,15 +19,20 @@ public class HomePage extends Initialization {
@FindBy(xpath = "//tbody/tr[1]/td[1]")
WebElement ConfirmText;
// Initialization
public HomePage() {
PageFactory.initElements(driver, this);
}
// Actions
public void insertText() throws InterruptedException {
public void insertText() throws InterruptedException, IOException {
JokesAPI jokesAPI = new JokesAPI();
jokesAPI.fetchJokes();
String setup = jokesAPI.getSetup();
String punchline = jokesAPI.getPunchline();
test = extent.createTest("Test msg");
message.sendKeys(setup+ " ==> " + punchline);
message.sendKeys(setup + " ==> " + punchline);
button.click();
extent.flush();
}

View File

@ -7,6 +7,8 @@ import org.testng.annotations.Test;
import zacksolutions.base.Initialization;
import zacksolutions.pages.HomePage;
import java.io.IOException;
public class HomePageTest extends Initialization {
HomePage homePage;
@ -22,7 +24,7 @@ public class HomePageTest extends Initialization {
}
@Test
public void TextTest() throws InterruptedException {
public void TextTest() throws InterruptedException, IOException {
System.out.println(driver.getTitle());
HomePage hp = new HomePage();
hp.insertText();