Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/test/java/com/solvd/carina/demo/MobilWorldWebTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@
import com.solvd.carina.demo.gui.mobilworld.components.PopUpLoginWindow;
import com.solvd.carina.demo.gui.mobilworld.components.TopMenu;
import com.solvd.carina.demo.gui.mobilworld.desktop.*;
import com.zebrunner.agent.core.annotation.TestRailCaseId;
import com.zebrunner.carina.core.AbstractTest;
import com.zebrunner.carina.utils.R;
import jdk.jfr.Name;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.Set;

public class MobilWorldWebTest extends AbstractTest {
private static final Logger LOGGER = LogManager.getLogger();

@Test
@TestRailCaseId("C3559")
public void testLogin() {
MainPage mainPage = new MainPage(getDriver());
mainPage.open();
Expand All @@ -33,6 +40,7 @@ public void testLogin() {
}

@Test
@TestRailCaseId("C3560")
public void addToCartIphone() {
String model = "iPhone 14 Pro Max";
String model2 = "iPhone 14 PRO Max 256 GB - Темно-фиолетовый";
Expand All @@ -56,6 +64,7 @@ public void addToCartIphone() {
}

@Test
@TestRailCaseId("C3561")
public void testDeleteItemsFromCart() {
String model = "iPhone 14 Pro Max";
String model2 = "iPhone 14 PRO Max 256 GB - Темно-фиолетовый";
Expand All @@ -82,6 +91,7 @@ public void testDeleteItemsFromCart() {
}

@Test
@TestRailCaseId("C3562")
public void testAllPagesAvailable() {
MainPage mainPage = new MainPage(getDriver());
mainPage.open();
Expand All @@ -104,6 +114,7 @@ public void testAllPagesAvailable() {
}

@Test
@TestRailCaseId("C3563")
public void testProductInfo() {
String model = "iPhone 14 Pro Max";
String model2 = "iPhone 14 PRO Max 256 GB - Темно-фиолетовый";
Expand Down Expand Up @@ -140,4 +151,26 @@ public void testSearchProducts() {

iphonePage.getModels().forEach(a -> LOGGER.info(a.getText()));
}

@Test(testName = "MobilWorld - testOpenWebSiteWithCookie")
public void testOpenWebSiteWithCookie() {
String cookieName = "session-username";
String cookieValue = "standard_user";
WebDriver driver = getDriver();
driver.get("https://www.saucedemo.com/");

Cookie cookie = new Cookie(cookieName, cookieValue);
driver.manage().addCookie(cookie);
driver.get("https://www.saucedemo.com/inventory.html");

Set<Cookie> cookies = driver.manage().getCookies();
boolean cookieFound = false;
for (Cookie cookie1 : cookies) {
if (cookie1.getName().equals(cookieName) && cookie1.getValue().equals(cookieValue)) {
cookieFound = true;
break;
}
}
Assert.assertTrue(cookieFound, "Cookie " + cookieName + " with value " + cookieValue + " not found");
}
}