package com.companyname.tests; import junit.framework.TestCase; import org.openqa.selenium.*; import java.awt.*; import java.awt.event.KeyEvent; import java.lang.reflect.Field; import java.util.concurrent.TimeUnit; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.Select; import org.openqa.selenium.chrome.ChromeDriver; import org.json.JSONArray; import org.json.JSONObject; /* // The source code was generated by javaSeleniumGenerator.js // Copyright: Tricentis // Website: https://www.tricentis.com // Java plugin version: 1.3.3 */ public class TestCase1 extends TestCase { private WebDriver driver = null; private Robot robot = null; private Boolean isFirefoxDriver = false; private static final Boolean alwaysExecuteActionInLatestWindow = true; private static final int MOUSE_LEFT = 0; private static final int MOUSE_RIGHT = 2; private static final int PAGE_LOAD_TIMEOUT = 60; public void setUp() throws Exception { System.setProperty("webdriver.chrome.driver", ""); driver = new ChromeDriver(); driver.manage().timeouts().pageLoadTimeout(PAGE_LOAD_TIMEOUT, TimeUnit.SECONDS); robot = new Robot(); driver.manage().window().maximize(); driver.get("https://www.flybuys.co.nz/"); } public void test() throws Exception { click(null, By.xpath("html/body/div[4]/div[2]/section[1]/div[1]/div/div/div/div[2]/div/div/h3/a"), MOUSE_LEFT, 1); sendKeys(null, By.id("autocomplete-0-input"), "umbrella", true, 6); click(null, By.xpath(".//*[@id='autocomplete-0-label']/button"), MOUSE_LEFT, 6); click(null, By.xpath(".//*[@id='instant-search-results-container']/div/div/ol/li[1]/div/div/a/div[1]/div[1]/div[1]/img"), MOUSE_LEFT, 8); selectItemByVisibleText(null, By.id("attribute234"), 6, "Choose an Option..." ); selectItemByVisibleText(null, By.id("attribute234"), 6, "Mint" ); click(null, By.xpath("html"), MOUSE_LEFT, 5); click(null, By.xpath(".//*[@id='product-addtocart-button']/span"), MOUSE_LEFT, 3); } public void tearDown() { driver.quit(); } public void click(String frames, By locator, int mouseButton, int timeoutInSeconds) throws Exception { click(frames, locator, mouseButton, null, timeoutInSeconds); } /* * try to click on an element, retry until the timeout is reached * */ public void click(String frames, By locator, int mouseButton, String combinedControlKeys, int timeoutInSeconds) throws Exception { if (alwaysExecuteActionInLatestWindow) switchToLastWindow(frames); Boolean success = false; long timeoutInMillies = timeoutInSeconds * 1000; WebElement elm = null; // indicate whether the element is an