Skip to content

Commit

Permalink
Added new assertTextContainsLoop method in Commands class.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwhit88 committed Sep 20, 2018
1 parent 6051ae2 commit 43e5fc2
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 75 deletions.
175 changes: 100 additions & 75 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file modified out/production/classes/framework/Commands.class
Binary file not shown.
Binary file modified out/production/classes/framework/PropsCommands.class
Binary file not shown.
Binary file not shown.
Binary file modified out/test/classes/frameworkSandbox/SelectDropdown.class
Binary file not shown.
12 changes: 12 additions & 0 deletions src/main/java/framework/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ public static void assertTextContains(WebElement el, String expValue, String des
}
CommandHelpers.printSteps(PropsCommands.assertTextContains, desc);
}

public static void assertTextContainsLoop(List<WebElement> elList, String expValue, String desc){
Boolean flag = false;
for (WebElement listItem : elList){
if (listItem.getText().contains(expValue)) {flag = true;}
}

if (!flag){
assertFalse(true, "Cannot find " + expValue + " in the list");
}
CommandHelpers.printSteps(PropsCommands.assertTextContainsLoop, desc);
}

public static void click(WebElement el, String desc){
el.click();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/framework/PropsCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public interface PropsCommands {
String enterText = "enterText";
String assertText = "assertText";
String assertTextContains = "assertTextContains";
String assertTextContainsLoop = "assertTextContainsLoop";
String assertInList = "assertInList";
String clickOffset = "clickOffset";
String fileUpload = "fileUpload";
Expand Down
45 changes: 45 additions & 0 deletions src/test/java/frameworkSandbox/AssertTextContainsLoop.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package frameworkSandbox;

import framework.Commands;
import framework.Drivers;
import framework.PropsSystem;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import java.io.File;
import java.util.List;

public class AssertTextContainsLoop {

public static WebDriver d;

@BeforeTest
public static void beforeTest(){
// d = Drivers.safariDriver("https://www.newegg.com/");
// d = Drivers.safariDriver(d, "http://sl-test.herokuapp.com/guinea_pig/file_upload");
// d = Drivers.firefoxDriver(d, "http://sl-test.herokuapp.com/guinea_pig/file_upload");
// d = Drivers.chromeDriver("http://sl-test.herokuapp.com/guinea_pig/file_upload");
File f = new File("/Users/darrinwhitley/Documents/workspace/slCreds");
d = Drivers.sauceLabsConfig(f, PropsSystem.chrome, "Windows 10", "https://www.xkcd.com");
d.manage().window().maximize();
PageFactory.initElements(d, AssertTextContainsLoop.class);
}

@Test
public static void test(){
waitPageLoad();
Commands.assertTextContainsLoop(nav, "Prev", "");
}

@FindBy(className = "comicNav")
public static List<WebElement> nav = null;

public static void waitPageLoad(){
Commands.waitForURL(d, "xkcd");
Commands.waitForEl(d, nav.get(0));
}
}

0 comments on commit 43e5fc2

Please sign in to comment.