Created
September 23, 2018 06:46
-
-
Save executeautomation/66ad268b1e4f35426be8f76e4cd6cb14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main.Addon; | |
import io.testproject.java.annotations.v2.Action; | |
import io.testproject.java.sdk.v2.addons.WebAction; | |
import io.testproject.java.sdk.v2.addons.helpers.WebAddonHelper; | |
import io.testproject.java.sdk.v2.drivers.WebDriver; | |
import io.testproject.java.sdk.v2.enums.ExecutionResult; | |
import io.testproject.java.sdk.v2.exceptions.FailureException; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebElement; | |
import java.util.ArrayList; | |
@Action(name="Click Menu Links") | |
public class ClickMenuLinks implements WebAction { | |
public ArrayList<String> menuItems = new ArrayList<>(); | |
@Override | |
public ExecutionResult execute(WebAddonHelper webAddonHelper) throws FailureException { | |
//Get Web Driver instance | |
WebDriver driver = webAddonHelper.getDriver(); | |
for(WebElement menu: driver.findElements(By.cssSelector(".navbar-fixed-top"))){ | |
if(!menu.isDisplayed()) | |
continue; | |
for (WebElement element: menu.findElements(By.tagName("li"))) { | |
menuItems.add(element.getText()); | |
} | |
//Click all the heading | |
for (String heading: menuItems) { | |
driver.findElementByLinkText(heading).click(); | |
} | |
} | |
return ExecutionResult.PASSED; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment