public object Decorate(MemberInfo member, IElementLocator locator) { FieldInfo field = member as FieldInfo; PropertyInfo property = member as PropertyInfo; Type targetType = null; targetType = field?.FieldType; bool hasPropertySet = false; if (property != null) { hasPropertySet = property.CanWrite; targetType = property?.PropertyType; } if (field == null & (property == null || !hasPropertySet)) { return(null); } if (field != null && (field.IsStatic || field.IsInitOnly)) { return(null); } Type aSingleElementType = GetTypeOfASingleElement(targetType, member); Type aListOfElementsType = null; if (GenericsUtility.MatchGenerics(typeof(IList <>), ListOfAvailableElementTypes, targetType)) { aListOfElementsType = targetType; } if (aSingleElementType == null & aListOfElementsType == null) { return(null); } ISearchContext context = locator.SearchContext; IEnumerable <By> bys = ByFactory.CreateBys(context, member); ProxyGenerator generator = new ProxyGenerator(); TimeOutDuration span = GetTimeWaitingForElements(member); bool shouldCache = (Attribute.GetCustomAttribute(member, typeof(CacheLookupAttribute), true) != null); if (aSingleElementType != null) { return(generator.CreateInterfaceProxyWithoutTarget(aSingleElementType, new Type[] { typeof(IWrapsDriver), typeof(IWrapsElement) }, ProxyGenerationOptions.Default, new ElementInterceptor(bys, locator, span, shouldCache))); } return(generator.CreateInterfaceProxyWithoutTarget(aListOfElementsType, ProxyGenerationOptions.Default, new ElementListInterceptor(bys, locator, span, shouldCache))); }
public void Before() { if (driver == null) { driver = new FirefoxDriver(); } duration = new TimeOutDuration(new TimeSpan(0, 0, 5)); PageFactory.InitElements(driver, this, new AppiumPageObjectMemberDecorator(duration)); }
public void BeforeAll() { TimeOutDuration timeSpan = new TimeOutDuration(new TimeSpan(0, 0, 0, 5, 0)); driver = new FirefoxDriver(); driver.Url = "https://www.google.com"; AppiumPageObjectMemberDecorator decorator = new AppiumPageObjectMemberDecorator(timeSpan); PageFactory.InitElements(driver, this, decorator); links = new FoundLinks(); PageFactory.InitElements(ires, links, decorator); }
public void BeforeAll() { DesiredCapabilities capabilities = Caps.getIos82Caps(Apps.get("iosTestApp")); if (Env.isSauce()) { capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME")); capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY")); capabilities.SetCapability("name", "ios - actions"); capabilities.SetCapability("tags", new string[] { "sample" }); } Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.LocalServiceURIForIOS; driver = new IOSDriver<AppiumWebElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC); TimeOutDuration timeSpan = new TimeOutDuration(new TimeSpan(0, 0, 0, 5, 0)); pageObject = new IOSPageObjectChecksAttributeMixOnNativeApp(); PageFactory.InitElements(driver, pageObject, new AppiumPageObjectMemberDecorator(timeSpan)); }
public void BeforeAll() { DesiredCapabilities capabilities = Env.isSauce() ? Caps.getAndroid501Caps(Apps.get("androidApiDemos")) : Caps.getAndroid19Caps(Apps.get("androidApiDemos")); if (Env.isSauce()) { capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME")); capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY")); capabilities.SetCapability("name", "android - complex"); capabilities.SetCapability("tags", new string[] { "sample" }); } Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.LocalServiceURIAndroid; driver = new AndroidDriver<AppiumWebElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC); TimeOutDuration timeSpan = new TimeOutDuration(new TimeSpan(0, 0, 0, 5, 0)); PageFactory.InitElements(driver, this, new AppiumPageObjectMemberDecorator(timeSpan)); }
public void BeforeAll() { DesiredCapabilities capabilities = Caps.getSelendroid16Caps(Apps.get("selendroidTestApp")); if (Env.isSauce()) { capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME")); capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY")); capabilities.SetCapability("name", "android - complex"); capabilities.SetCapability("tags", new string[] { "sample" }); } Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.localURI; driver = new AndroidDriver<AppiumWebElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC); TimeOutDuration timeSpan = new TimeOutDuration(new TimeSpan(0, 0, 0, 5, 0)); pageObject = new AndroidPageObjectChecksSelendroidModeOnNativeApp(); PageFactory.InitElements(driver, pageObject, new AppiumPageObjectMemberDecorator(timeSpan)); }
public void BeforeAll() { DesiredCapabilities capabilities = Env.isSauce() ? Caps.getAndroid18Caps(Apps.get("selendroidTestApp")) : Caps.getAndroid19Caps(Apps.get("selendroidTestApp")); if (Env.isSauce()) { capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME")); capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY")); capabilities.SetCapability("name", "android - webview"); capabilities.SetCapability("tags", new string[] { "sample" }); } Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.localURI; driver = new AndroidDriver<AppiumWebElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC); TimeOutDuration timeSpan = new TimeOutDuration(new TimeSpan(0, 0, 0, 5, 0)); pageObject = new AndroidWebView(); PageFactory.InitElements(driver, pageObject, new AppiumPageObjectMemberDecorator(timeSpan)); driver.StartActivity("io.selendroid.testapp", ".WebViewActivity"); }
public AppiumPageObjectMemberDecorator(TimeOutDuration timeForWaitingForElements) { this.timeForWaitingForElements = timeForWaitingForElements; }
public AndroidJavaScriptTestPageObject(IWebDriver driver) { this.driver = driver; TimeOutDuration timeSpan = new TimeOutDuration(new TimeSpan(0, 0, 0, 5, 0)); PageFactory.InitElements(driver, this, new AppiumPageObjectMemberDecorator(timeSpan)); }