Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"SelectMethod Exception & DragNdrop Test" #1316

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions src/main/java/com/shaft/gui/element/ElementActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,16 @@ public ElementActions select(By elementLocator, String valueOrVisibleText) {
click(elementInformation.getLocator());
elementInformation = ElementInformation.fromList(ElementActionsHelper.
identifyUniqueElement((WebDriver) DriverFactoryHelper.getDriver().get(), elementLocator));
RelativeLocator.RelativeBy relativeBy = null;
try {
relativeBy = SHAFT.GUI.Locator.hasAnyTagName().and().containsText(valueOrVisibleText).relativeBy().below(elementInformation.getLocator());
} catch (Exception e) {
RelativeLocator.RelativeBy relativeBy = SHAFT.GUI.Locator.hasAnyTagName().and().containsText(valueOrVisibleText).relativeBy().below(elementInformation.getLocator());
elementInformation = ElementInformation.fromList(ElementActionsHelper.
identifyUniqueElement((WebDriver) DriverFactoryHelper.getDriver().get(), relativeBy));
} catch (Throwable var9) {
ReportManager.logDiscrete("Cannot Find Element with the following Locator in the DropDown Options: " + By.xpath("//*[text()='" + valueOrVisibleText + "']"));
ElementActionsHelper.failAction((WebDriver) DriverFactoryHelper.getDriver().get(),
valueOrVisibleText, By.xpath("//*[text()='" + valueOrVisibleText + "']"), e);
By.xpath("//*[text()='" + valueOrVisibleText + "']").toString(), elementLocator, var9);
}
click(relativeBy);
click(elementInformation.getLocator());
}
else {
ReportManager.logDiscrete("Cannot Find Element with the following Locator in the DropDown Options: " + By.xpath("//*[text()='" + valueOrVisibleText + "']"));
Expand Down
38 changes: 38 additions & 0 deletions src/test/java/testPackage/appium/DragAndDropTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package testPackage.appium;

import com.shaft.driver.SHAFT;
import io.appium.java_client.AppiumBy;
import io.appium.java_client.remote.AutomationName;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class DragAndDropTest {
private SHAFT.GUI.WebDriver driver;
private final AppiumBy dragBtn = new AppiumBy.ByAndroidUIAutomator("UiSelector().text(\"Drag\")");
private final By toBeDragged = By.xpath("//android.view.ViewGroup[@content-desc=\"drag-l1\"]/android.widget.ImageView");
private final By toBeDropped =By.xpath("//android.view.ViewGroup[@content-desc=\"drop-l1\"]/android.view.ViewGroup");
@BeforeMethod
public void setupUp(){
System.setProperty("mobile_autoGrantPermissions", "true");
SHAFT.Properties.platform.set().targetPlatform(Platform.ANDROID.name());
SHAFT.Properties.mobile.set().automationName(AutomationName.ANDROID_UIAUTOMATOR2);
SHAFT.Properties.platform.set().executionAddress("127.0.0.1:4754");
SHAFT.Properties.mobile.set().deviceName("Pixel 4 API 28");
SHAFT.Properties.mobile.set().app("src/test/resources/testDataFiles/apps/wdio-demo.apk");
driver = new SHAFT.GUI.WebDriver();
}

@Test
public void testDragAndDrop(){
driver.element().touch().tap(dragBtn);
driver.element().touch().swipeToElement(toBeDragged, toBeDropped);
}

@AfterMethod(alwaysRun = true)
public void teardown() {
driver.quit();
}
}
8 changes: 7 additions & 1 deletion src/test/java/testPackage/unitTests/SelectMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ protected void setUp() {

}
@Test
public void testSelect(){
public void testValidSelect(){
login("Admin","admin123")
.clickDropDownList("Support");
}

@Test
public void testInvalidSelect(){
login("Admin","admin123")
.clickDropDownList("sds");
}

@AfterMethod
protected void tearDown(){ driver.get().quit();}

Expand Down
Binary file not shown.