ok, now is working the MobileBy!
Now when I run the test the problem is the âios class chainâ
Im using this line: driver.findElement(MobileBy. iOSClassChain (â/XCUIElementTypeCollectionView//XCUIElementTypeCell[1]â)).click();
And the log say:
org.openqa.selenium.InvalidSelectorException: invalid selector (Locator Strategy â-ios class chainâ is not supported for this session) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
My code
tests file
package tests;
import java.net.MalformedURLException;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import io.appium.java_client.MobileBy;
public class PROES_Searchitem extends BaseTest {
public PROES_Searchitem() throws MalformedURLException {
super();
// TODO Auto-generated constructor stub
}
@Test
public void probarseleccionararticulosinnombre() {
new WebDriverWait(driver, 30).until(ExpectedConditions. presenceOfElementLocated (By. xpath (â//*[@text=âBusca por producto, colecciĂłn o palabra claveâ]â))).click();
new WebDriverWait(driver, 30).until(ExpectedConditions. presenceOfElementLocated (By. name (âsearch_searchTextFieldâ))).click();
driver.findElement(By. name (âsearch_searchTextFieldâ)).sendKeys(âvestidoâ);
driver.findElement(By. name (âbuscarâ)).click();
new WebDriverWait(driver, 30).until(ExpectedConditions. presenceOfElementLocated (By. name (âFiltrosâ)));
driver.findElement(MobileBy. iOSClassChain (â/XCUIElementTypeCollectionView//XCUIElementTypeCell[1]â)).click(); // replace XCUIElementTypeStaticText
with your element type of âITEM 1â
new WebDriverWait(driver, 30).until(ExpectedConditions. presenceOfElementLocated (By. id (âproductDetail_buySelectSizeButtonâ))).click();
new WebDriverWait(driver, 30).until(ExpectedConditions. presenceOfElementLocated (By. id (âproductDetail_buySelectSizeButtonâ))).click();
new WebDriverWait(driver, 30).until(ExpectedConditions. presenceOfElementLocated (By. id (âTramitar pedidoâ))).click();
new WebDriverWait(driver, 30).until(ExpectedConditions. presenceOfElementLocated (By. name (âTRAMITAR PEDIDOâ)));
}
@AfterMethod
public void tearDown() {
driver.quit();
}
}
baseTest file
package tests;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.remote.IOSMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
public class BaseTest {
private String reportDirectory = âreportsâ;
private String reportFormat = âxmlâ;
private String testName = âPROES-Searchitemâ;
protected IOSDriver driver = null;
public BaseTest() throws MalformedURLException {
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(âreportDirectoryâ, reportDirectory);
dc.setCapability(âreportFormatâ, reportFormat);
dc.setCapability(âtestNameâ, testName);
dc.setCapability(MobileCapabilityType.UDID, âE4F6EDC4-E23C-42B3-987D-3DB282CA77C1â);
dc.setCapability(IOSMobileCapabilityType.BUNDLE_ID, âcom.app.beta.test.testappsâ);
driver = new IOSDriver<>(new URL(âhttp://localhost:4723/wd/hubâ), dc);
driver.setLogLevel(Level.INFO);
}
}