diff --git a/src/com/qmetry/qaf/automation/step/CommonStep.java b/src/com/qmetry/qaf/automation/step/CommonStep.java index 38f3b76..65451cd 100644 --- a/src/com/qmetry/qaf/automation/step/CommonStep.java +++ b/src/com/qmetry/qaf/automation/step/CommonStep.java @@ -42,6 +42,7 @@ import org.hamcrest.Matchers; import org.openqa.selenium.Cookie; +import org.openqa.selenium.interactions.Actions; import com.qmetry.qaf.automation.core.TestBaseProvider; import com.qmetry.qaf.automation.data.MetaData; @@ -50,6 +51,7 @@ import com.qmetry.qaf.automation.ui.WebDriverTestBase; import static com.qmetry.qaf.automation.ui.webdriver.ElementFactory.$; import com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebElement; +import com.qmetry.qaf.automation.ui.webdriver.QAFWebElement; import com.qmetry.qaf.automation.util.StringUtil; import com.qmetry.qaf.automation.ws.rest.RestTestBase; import com.sun.jersey.api.client.ClientResponse; @@ -323,12 +325,12 @@ public static void get(String url) { * current thread. Note that it will not tear-down the current driver * session. *

- * It is useful for some use cases involving browser and device - * - There are some use cases involving more than 2 devices/browsers (ex.: - * video conference) + * It is useful for some use cases involving browser and device - There are + * some use cases involving more than 2 devices/browsers (ex.: video + * conference) *

- * For single driver in entire test case you don't required to use - * this method. + * For single driver in entire test case you don't required to use this + * method. * * @since 2.1.11 * @param driverName @@ -414,9 +416,7 @@ public static void requestForResource(String resource, Map param private static void requestFor(String resource, Map params) { WebResource webResource = new RestTestBase().getWebResource( - getBundle().getString("ws.endurl", - ApplicationProperties.SELENIUM_BASE_URL.getStringVal()), - resource); + getBundle().getString("ws.endurl", ApplicationProperties.SELENIUM_BASE_URL.getStringVal()), resource); if (null != params && !params.isEmpty()) { MultivaluedMap mparams = new MultivaluedMapImpl(); @@ -471,8 +471,7 @@ public static void requestForResource(String resource) { */ @QAFTestStep(description = "user post {content} for resource {resource}") public static void postContent(String content, String resource) { - new RestTestBase().getWebResource(getBundle().getString("ws.endurl"), resource) - .post(content); + new RestTestBase().getWebResource(getBundle().getString("ws.endurl"), resource).post(content); } /** @@ -519,8 +518,7 @@ public static void response_should_have_status(String status) { */ @QAFTestStep(description = "response should have status code {statusCode}") public static void response_should_have_statuscode(int statusCode) { - assertThat("Response Status", - new RestTestBase().getResponse().getStatus().getStatusCode(), + assertThat("Response Status", new RestTestBase().getResponse().getStatus().getStatusCode(), Matchers.equalTo(statusCode)); } @@ -543,8 +541,7 @@ public static void response_should_have_statuscode(int statusCode) { */ @QAFTestStep(description = "response should have xpath {xpath}") public static void response_should_have_xpath(String xpath) { - assertThat(the(new RestTestBase().getResponse().getMessageBody()), - hasXPath(xpath)); + assertThat(the(new RestTestBase().getResponse().getMessageBody()), hasXPath(xpath)); } /** @@ -645,6 +642,38 @@ public static void click(String loc) { $(loc).click(); } + /** + * A convenience step for drag and drop that performs click-and-hold at the location of the + * source element, moves to the location of the target element, then + * releases the mouse. + * + *

+ * Example: + *

+ * BDD + *

+ * + * drag 'source.ele.loc' and drop on 'target.ele.loc'
+ *
+ *

+ * KWD + *

+ * + * dragAndDrop|['source.ele.loc','target.ele.loc']| + * + * @param source + * : {0} : source element locator to emulate button down at. + * @param target + * : {1} : target element locator to move to and release the + * mouse at. + */ + @QAFTestStep(description = "drag {source} and drop on {target}") + public static void dragAndDrop(String source, String target) { + QAFExtendedWebElement src = (QAFExtendedWebElement) $(source); + Actions actions = new Actions(src.getWrappedDriver()); + actions.dragAndDrop(src, $(target)); + } + /** * Wait for the specified element is visible Determines if the specified * element is visible. An element can be rendered invisible by setting the @@ -792,7 +821,8 @@ public static void waitForEnabled(String loc, long sec) { */ @QAFTestStep(description = "wait until {loc} to be present") public static void waitForPresent(String loc) { - $(loc).waitForPresent();; + $(loc).waitForPresent(); + ; } @@ -1098,8 +1128,7 @@ public static void waitForNotAttribute(String loc, String attr, String value) { // @QAFTestStep(stepName = "waitForNotAttributeWithTimeout", description = // "wait {3}sec for {0} attribute {1} value is not {2}") - public static void waitForNotAttribute(String loc, String attr, String value, - long sec) { + public static void waitForNotAttribute(String loc, String attr, String value, long sec) { $(loc).waitForAttribute(attr, value, sec * 1000); } @@ -1235,8 +1264,7 @@ public static void waitForNotCssStyle(String loc, String prop, String value) { // @QAFTestStep(stepName = "waitForNotCssStyleWithTimeout", description = // "wait {3}sec for {0} css property {1} vaule is {2} ") - public static void waitForNotCssStyle(String loc, String prop, String value, - long sec) { + public static void waitForNotCssStyle(String loc, String prop, String value, long sec) { $(loc).waitForNotCssStyle(prop, value, sec * 1000); } @@ -1281,18 +1309,12 @@ public static void waitForAjaxToComplete() { * Will check and wait until in-progress AJAX call get completed from * provide toolkit. Following are supported toolkit: *