예제 #1
0
 protected AppiumDriver <AppiumWebElement> GetMobileDriver(string browser)
 {
     return(DriverHelper.FactoryMobileDriver(browser));
 }
예제 #2
0
        public void acceptCookies()

        {
            DriverHelper.ClickOnElement(acceptCookiesSelector);
        }
예제 #3
0
 public AmazonSteps(DriverHelper driverHelper)
 {
     _driverHelper = driverHelper;
     homePage      = new HomePage(_driverHelper.Driver);
     productPage   = new productPage(_driverHelper.Driver);
 }
 public IWebDriver GetWebDriver(string browser)
 {
     return(DriverHelper.FactoryWebDriver(browser));
 }
예제 #5
0
 public TrendyolLoginSteps(DriverHelper driverHelper)
 {
     _driverHelper = driverHelper;
     loginPage     = new LoginPage(_driverHelper.Driver);
 }
예제 #6
0
 public EaAPPSteps(DriverHelper driverhelper)
 {
     _driverhelper = driverhelper;
     home          = new HomePage(_driverhelper.driver);
     login         = new LoginPage(_driverhelper.driver);
 }
예제 #7
0
 public Hooks1(DriverHelper driverHelper) => _driverHelper = driverHelper;
예제 #8
0
 public void CloseBrowser()
 {
     DriverHelper.GetWebDriver().Quit();
 }
예제 #9
0
        /// <summary>
        /// Send raw HTTP request to the server and request the map tiles around the coords. This mimics browser on the map page.
        /// </summary>
        public static List <MapTile> GetMapTiles(Account acc, Coordinates coords)
        {
            switch (acc.AccInfo.ServerVersion)
            {
            case Classificator.ServerVersionEnum.T4_4:
                var ajaxToken = DriverHelper.GetJsObj <string>(acc, "ajaxToken");

                var req = new RestSharp.RestRequest
                {
                    Resource = "/ajax.php?cmd=mapPositionData",
                    Method   = Method.POST,
                };

                req.AddParameter("cmd", "mapPositionData");
                req.AddParameter("data[x]", coords.x.ToString());
                req.AddParameter("data[y]", coords.y.ToString());
                req.AddParameter("data[zoomLevel]", "3");
                req.AddParameter("ajaxToken", ajaxToken);

                var resString = HttpHelper.SendPostReq(acc, req);

                var root = JsonConvert.DeserializeObject <MapPositionDataT4_4.Root>(resString);
                if (root.response.error)
                {
                    throw new Exception("Unable to get T4.4 map position data!\n" + root.response.error);
                }
                return(root.response.data.tiles.Select(x => x.GetMapTile()).ToList());

            case Classificator.ServerVersionEnum.T4_5:
                var bearerToken = DriverHelper.GetBearerToken(acc);

                var reqMapInfo = new RestSharp.RestRequest
                {
                    Resource      = "/api/v1/ajax/mapInfo",
                    Method        = Method.POST,
                    RequestFormat = DataFormat.Json
                };
                reqMapInfo.AddHeader("authorization", $"Bearer {bearerToken}");
                reqMapInfo.AddHeader("content-type", "application/json; charset=UTF-8");
                reqMapInfo.AddJsonBody(GenerateMapInfo(coords));

                var mapInfoRes = HttpHelper.SendPostReq(acc, reqMapInfo);

                var mapPosition = new SendMapPositionT4_5.Root()
                {
                    data = new SendMapPositionT4_5.Data()
                    {
                        x               = coords.x,
                        y               = coords.y,
                        zoomLevel       = 3,
                        ignorePositions = new List <object>()
                    }
                };

                var reqMapPosition = new RestSharp.RestRequest
                {
                    Resource      = "/api/v1/ajax/mapPositionData",
                    Method        = Method.POST,
                    RequestFormat = DataFormat.Json
                };
                reqMapPosition.AddHeader("authorization", $"Bearer {bearerToken}");
                reqMapPosition.AddHeader("content-type", "application/json; charset=UTF-8");
                reqMapPosition.AddJsonBody(mapPosition);

                var mapPositionRes  = HttpHelper.SendPostReq(acc, reqMapPosition);
                var mapPositionData = JsonConvert.DeserializeObject <MapPositionDataT4_5>(mapPositionRes);
                return(mapPositionData.tiles.Select(x => x.GetMapTile()).ToList());
            }
            return(null);
        }
예제 #10
0
 public SignInPage(IWebDriver driver)
 {
     Driver       = driver;
     driverHelper = new DriverHelper(Driver);
 }
예제 #11
0
 public NavLinksSteps(DriverHelper driverHelper) => _driverHelper = driverHelper;
        public override async Task <TaskRes> Execute(Account acc)
        {
            await acc.Wb.Navigate($"{acc.AccInfo.ServerUrl}/karte.php");

            Coordinates closesCoords = null;

            var mainVill = AccountHelper.GetMainVillage(acc);

            switch (acc.AccInfo.ServerVersion)
            {
            case Classificator.ServerVersionEnum.T4_4:
                var ajaxToken = DriverHelper.GetJsObj <string>(acc, "ajaxToken");

                var req = new RestRequest
                {
                    Resource = "/ajax.php?cmd=mapPositionData",
                    Method   = Method.POST,
                };

                req.AddParameter("cmd", "mapPositionData");
                req.AddParameter("data[x]", mainVill.Coordinates.x.ToString());
                req.AddParameter("data[y]", mainVill.Coordinates.y.ToString());
                req.AddParameter("data[zoomLevel]", "3");
                req.AddParameter("ajaxToken", ajaxToken);

                var resString = HttpHelper.SendPostReq(acc, req);

                var root = JsonConvert.DeserializeObject <MapPositionDataT4_4.Root>(resString);
                if (root.response.error)
                {
                    throw new Exception("Unable to get T4.4 map position data!\n" + root.response.error);
                }

                var mapTiles = root.response.data.tiles.Select(x => x.GetMapTile()).ToList();
                closesCoords = GetClosestCoordinates(acc, mapTiles);
                break;

            case Classificator.ServerVersionEnum.T4_5:
                var bearerToken = DriverHelper.GetBearerToken(acc);

                var reqMapInfo = new RestRequest
                {
                    Resource      = "/api/v1/ajax/mapInfo",
                    Method        = Method.POST,
                    RequestFormat = DataFormat.Json
                };
                reqMapInfo.AddHeader("authorization", $"Bearer {bearerToken}");
                reqMapInfo.AddHeader("content-type", "application/json; charset=UTF-8");
                reqMapInfo.AddJsonBody(GenerateMapInfo(mainVill.Coordinates));

                var mapInfoRes = HttpHelper.SendPostReq(acc, reqMapInfo);

                var mapPosition = new SendMapPositionT4_5.Root()
                {
                    data = new SendMapPositionT4_5.Data()
                    {
                        x               = mainVill.Coordinates.x,
                        y               = mainVill.Coordinates.y,
                        zoomLevel       = 3,
                        ignorePositions = new List <object>()
                    }
                };

                var reqMapPosition = new RestRequest
                {
                    Resource      = "/api/v1/ajax/mapPositionData",
                    Method        = Method.POST,
                    RequestFormat = DataFormat.Json
                };
                reqMapPosition.AddHeader("authorization", $"Bearer {bearerToken}");
                reqMapPosition.AddHeader("content-type", "application/json; charset=UTF-8");
                reqMapPosition.AddJsonBody(mapPosition);
                //reqMapPosition.AddParameter("application/json", , ParameterType.RequestBody);
                var mapPositionRes  = HttpHelper.SendPostReq(acc, reqMapPosition);
                var mapPositionData = JsonConvert.DeserializeObject <MapPositionDataT4_5>(mapPositionRes);

                var mapTilesT45 = mapPositionData.tiles.Select(x => x.GetMapTile()).ToList();
                closesCoords = GetClosestCoordinates(acc, mapTilesT45);
                break;
            }

            if (closesCoords == null)
            {
                return(TaskRes.Retry);
            }

            acc.NewVillages.Locations.Add(new NewVillage()
            {
                Coordinates = closesCoords,
                Name        = NewVillageHelper.GenerateName(acc),
            });

            return(TaskRes.Executed);
        }
예제 #13
0
 public AccessibilityTestsFixture()
 {
     factory = new SeleniumServerFactory <TStartup>();
     BaseUrl = factory.RootUri;
     Driver  = DriverHelper.CreateHeadlessChromeDriver();
 }
예제 #14
0
        /// <summary>
        /// Tries to watch an Ad for +25% faster upgrade
        /// </summary>
        /// <param name="acc">Account</param>
        /// <returns>Whether bot watched the ad</returns>
        private async Task <bool> TryFastUpgrade(Account acc)
        {
            if (!await DriverHelper.ClickByClassName(acc, "videoFeatureButton green", false))
            {
                return(false);
            }
            await System.Threading.Tasks.Task.Delay(AccountHelper.Delay());

            // Confirm
            acc.Wb.UpdateHtml();
            if (acc.Wb.Html.DocumentNode.SelectSingleNode("//input[@name='adSalesVideoInfoScreen']") != null)
            {
                await DriverHelper.ClickByName(acc, "adSalesVideoInfoScreen");

                await System.Threading.Tasks.Task.Delay(AccountHelper.Delay());

                await DriverHelper.ExecuteScript(acc, "jQuery(window).trigger('showVideoWindowAfterInfoScreen')");

                await System.Threading.Tasks.Task.Delay(AccountHelper.Delay());
            }

            // Has to be a legit "click"
            acc.Wb.Driver.FindElementById("videoFeature").Click();

            // wait for finish watching ads
            var timeout = DateTime.Now.AddSeconds(100);

            do
            {
                await System.Threading.Tasks.Task.Delay(3000);

                //skip ads from Travian Games
                //they use ifarme to emebed ads video to their game
                acc.Wb.UpdateHtml();
                if (acc.Wb.Html.GetElementbyId("videoArea") != null)
                {
                    acc.Wb.Driver.SwitchTo().Frame(acc.Wb.Driver.FindElementById("videoArea"));
                    // trick to skip
                    await DriverHelper.ExecuteScript(acc, "var video = document.getElementsByTagName('video')[0];video.currentTime = video.duration - 1;", false, false);

                    //back to first page
                    acc.Wb.Driver.SwitchTo().DefaultContent();
                }
                if (timeout < DateTime.Now)
                {
                    return(false);
                }
            }while (acc.Wb.Driver.Url.Contains("build.php"));

            // Don't show again
            acc.Wb.UpdateHtml();
            if (acc.Wb.Html.GetElementbyId("dontShowThisAgain") != null)
            {
                await DriverHelper.ClickById(acc, "dontShowThisAgain");

                await System.Threading.Tasks.Task.Delay(AccountHelper.Delay());

                await DriverHelper.ClickByClassName(acc, "dialogButtonOk ok");
            }

            return(true);
        }
예제 #15
0
 public LoginSteps(DriverHelper driverHelper)
 {
     _driverHelper = driverHelper;
     homePage      = new HomePage(_driverHelper.Driver);
     loginPage     = new LoginPage(_driverHelper.Driver);
 }
예제 #16
0
        /// <summary>
        /// Building is already constructed, upgrade it
        /// </summary>
        /// <param name="acc">Account</param>
        /// <returns>TaskResult</returns>
        private async Task <TaskRes> Upgrade(Account acc, HtmlNode node)
        {
            (var buildingEnum, var lvl) = InfrastructureParser.UpgradeBuildingGetInfo(node);

            if (buildingEnum == BuildingEnum.Site || lvl == -1)
            {
                acc.Wb.Log($"Can't upgrade building {this.Task.Building} in village {this.Vill.Name}. Will be removed from the queue.");
                RemoveCurrentTask();
                return(TaskRes.Executed);
            }

            // If there is already a different building in this spot, find a new id to construct it.
            if (buildingEnum != Task.Building)
            {
                acc.Wb.Log($"We wanted to upgrade {Task.Building}, but there's already {buildingEnum} on this id ({Task.BuildingId}).");
                if (!BuildingHelper.FindBuildingId(Vill, this.Task))
                {
                    acc.Wb.Log($"Found another Id to build {Task.Building}, new id: {Task.BuildingId}");
                    return(TaskRes.Retry);
                }
                acc.Wb.Log($"Failed to find another Id to build {Task.Building}! No space in village. Building task will be removed");
                RemoveCurrentTask();
                return(TaskRes.Executed);
            }

            // Basic task already on/above desired level, don't upgrade further
            var building = Vill.Build.Buildings.FirstOrDefault(x => x.Id == this.Task.BuildingId);

            lvl = building.Level;
            if (building.UnderConstruction)
            {
                lvl++;
            }
            if (lvl >= Task.Level)
            {
                acc.Wb.Log($"{this.Task.Building} is on level {lvl}, on/above desired {Task.Level}. Removing it from queue.");
                RemoveCurrentTask();
                RemoveCompletedTasks(this.Vill, acc);
                return(TaskRes.Executed);
            }

            var container = acc.Wb.Html.DocumentNode.Descendants("div").FirstOrDefault(x => x.HasClass("upgradeButtonsContainer"));
            var buttons   = container?.Descendants("button");

            if (buttons == null)
            {
                acc.Wb.Log($"We wanted to upgrade {Task.Building}, but no 'upgrade' button was found! Url={acc.Wb.CurrentUrl}");
                return(TaskRes.Retry);
            }

            var errorMessage = acc.Wb.Html.GetElementbyId("build")
                               .Descendants("div")
                               .FirstOrDefault(x => x.HasClass("upgradeBuilding"))?
                               .Descendants("div")?
                               .FirstOrDefault(x => x.HasClass("errorMessage"));
            HtmlNode upgradeButton = buttons.FirstOrDefault(x => x.HasClass("build"));

            if (upgradeButton == null)
            {
                acc.Wb.Log($"We wanted to upgrade {Task.Building}, but no 'upgrade' button was found!");
                return(TaskRes.Retry);
            }

            // Not enough resources?
            if (acc.AccInfo.ServerVersion == ServerVersionEnum.T4_5 && errorMessage != null)
            {
                acc.Wb.Log($"We wanted to upgrade {Task.Building}, but there was an error message:\n{errorMessage.InnerText}");
                return(TaskRes.Retry);
            }

            var buildDuration = InfrastructureParser.GetBuildDuration(container, acc.AccInfo.ServerVersion);

            if (IsTaskCompleted(Vill, acc, this.Task))
            {
                acc.Wb.Log($"Building {this.Task.Building} in village {this.Vill.Name} is already on desired level. Will be removed from the queue.");
                RemoveCurrentTask();
                return(TaskRes.Executed);
            }
            //TODO move this
            CheckSettlers(acc, Vill, lvl, DateTime.Now.Add(buildDuration));

            if (acc.AccInfo.ServerVersion == ServerVersionEnum.T4_4 ||
                buildDuration.TotalMinutes <= acc.Settings.WatchAdAbove ||
                !await TryFastUpgrade(acc))                          // +25% speed upgrade
            {
                await DriverHelper.ClickById(acc, upgradeButton.Id); // Normal upgrade
            }

            lvl++;
            CheckIfTaskFinished(lvl);

            acc.Wb.Log($"Started upgrading {this.Task.Building} to level {lvl} in {this.Vill?.Name}");
            await PostTaskCheckDorf(acc);

            return(TaskRes.Executed);
        }
예제 #17
0
        public override async Task <TaskRes> Execute(Account acc)
        {
            var wb = acc.Wb.Driver;

            if (!await VillageHelper.EnterBuilding(acc, Vill, Classificator.BuildingEnum.Marketplace, "&t=0"))
            {
                return(TaskRes.Executed);
            }

            var npcMerchant = acc.Wb.Html.DocumentNode.Descendants("div").FirstOrDefault(x => x.HasClass("npcMerchant"));
            var npcButton   = npcMerchant.Descendants("button").FirstOrDefault(x => x.HasClass("gold"));

            // Exchange resources button
            await DriverHelper.ClickById(acc, npcButton.Id);

            //wait npc form show
            var timeout = DateTime.Now.AddSeconds(100);

            HtmlNode remainRes = null;

            do
            {
                await Task.Delay(1000);

                remainRes = acc.Wb.Html.GetElementbyId("remain");

                if (timeout < DateTime.Now)
                {
                    acc.Wb.Log($"NPC in village {Vill.Name} is time out. Retry after 3 mins");
                    this.NextExecute = DateTime.Now.AddMinutes(3);
                    return(TaskRes.Executed);
                }
            }while (remainRes == null);

            var resSum    = Parser.RemoveNonNumeric(remainRes.InnerText);
            var targetRes = MarketHelper.NpcTargetResources(Vill, resSum);

            if (!Vill.Market.Npc.NpcIfOverflow && MarketHelper.NpcWillOverflow(Vill, targetRes))
            {
                acc.Wb.Log($"NPC in village {Vill.Name} will be overflow. Stop NPC");
                return(TaskRes.Executed);
            }
            for (int i = 0; i < 4; i++)
            {
                //await acc.Wb.Driver.FindElementById($"m2[{i}]").Write(targetRes[i]);
                switch (acc.AccInfo.ServerVersion)
                {
                case Classificator.ServerVersionEnum.T4_4:
                    await DriverHelper.ExecuteScript(acc, $"document.getElementById('m2[{i}]').value='{targetRes[i]}'");

                    break;

                case Classificator.ServerVersionEnum.T4_5:
                    await DriverHelper.ExecuteScript(acc, $"document.getElementsByName('desired{i}')[0].value='{targetRes[i]}'");

                    break;
                }
            }

            var submit     = acc.Wb.Html.GetElementbyId("submitText");
            var distribute = submit.Descendants("button").FirstOrDefault();

            await DriverHelper.ClickById(acc, distribute.Id);

            await DriverHelper.ClickById(acc, "npc_market_button");

            return(TaskRes.Executed);
        }
예제 #18
0
 public IWebElement FindWebElementAndWait(By by) => DriverHelper.FindWebElementAndWait(Driver, by);
예제 #19
0
        public override async Task <TaskRes> Execute(Account acc)
        {
            await acc.Wb.Navigate($"{acc.AccInfo.ServerUrl}/karte.php");

            await Task.Delay(AccountHelper.Delay() * 3);

            // Check if the account has enough culture points
            if (acc.AccInfo.CulturePoints.MaxVillages <= acc.AccInfo.CulturePoints.VillageCount)
            {
                // TODO: this shouldn't be here?
                this.Vill.Expansion.ExpansionAvailable = true;
                return(TaskRes.Executed);
            }

            if (acc.NewVillages.Locations.Count == 0)
            {
                if (acc.NewVillages.AutoFindVillages) // Find new village to settle
                {
                    TaskExecutor.AddTaskIfNotExists(acc, new FindVillageToSettle()
                    {
                        Vill      = AccountHelper.GetMainVillage(acc),
                        ExecuteAt = DateTime.MinValue.AddHours(10)
                    });
                    this.NextExecute = DateTime.MinValue.AddHours(11);
                }

                return(TaskRes.Executed);
            }

            var newVillage = acc.NewVillages.Locations.FirstOrDefault();

            //acc.NewVillage.NewVillages.Remove(coords); //remove it after settling and changing the vill name??
            string kid = MapHelper.KidFromCoordinates(newVillage.Coordinates, acc).ToString();

            string url = $"{acc.AccInfo.ServerUrl}/build.php?id=39&tt=2";

            switch (acc.AccInfo.ServerVersion)
            {
            case Classificator.ServerVersionEnum.T4_4:
                // https://low4.ttwars.com/build.php?id=39&tt=2&kid=7274&a=6
                url += $"&kid={kid}&a=6";
                break;

            case Classificator.ServerVersionEnum.T4_5:
                // https://tx3.travian.com/build.php?id=39&tt=2&mapid=123&s=1&gid=16
                url += $"&mapid={kid}&s=1&gid=16";
                break;
            }
            await acc.Wb.Navigate(url);

            //TODO: check if enough resources!!
            if (!await DriverHelper.ClickById(acc, "btn_ok"))
            {
                return(TaskRes.Retry);
            }

            newVillage.SettlersSent = true;
            this.Vill.Expansion.ExpansionAvailable = false;

            return(TaskRes.Executed);
        }
예제 #20
0
 public IList <IWebElement> FindWebElementsAndWait(By by) => DriverHelper.FindWebElementsAndWait(Driver, by);
 public AppiumDriver <AppiumWebElement> GetDriver(string type)
 {
     return(DriverHelper.FactoryMobileDriver(type));
 }
예제 #22
0
 public IWebElement FindWebElement(By by) => DriverHelper.FindWebElementWithoutWait(Driver, by);
예제 #23
0
 public ShoppingCartPage(IWebDriver driver)
 {
     Driver       = driver;
     driverHelper = new DriverHelper(Driver);
     signInPage   = new SignInPage(Driver);
 }
예제 #24
0
 public IList <IWebElement> FindWebElements(By by) => DriverHelper.FindWebElementsWithoutWait(Driver, by);
예제 #25
0
 public void navigateToHomePage(String url)
 {
     DriverHelper.NavigateToUlr(url);
 }
예제 #26
0
        public override async Task <TaskRes> Execute(Account acc)
        {
            var wb = acc.Wb.Driver;
            await acc.Wb.Navigate($"{acc.AccInfo.ServerUrl}/build.php?tt=99&id=39");

            var flNode = GetFlNode(acc.Wb.Html, acc.AccInfo.ServerVersion);

            // If there is no rally point, switch to different village
            if (flNode == null)
            {
                var mainVill = AccountHelper.GetMainVillage(acc);
                if (mainVill == this.Vill)
                {
                    return(TaskRes.Executed);                       // No gold account?
                }
                await VillageHelper.SwitchVillage(acc, mainVill.Id);

                flNode = GetFlNode(acc.Wb.Html, acc.AccInfo.ServerVersion);
                if (flNode == null)
                {
                    return(TaskRes.Retry);
                }
            }

            if (acc.Farming.TrainTroopsAfterFL) // For TTWars servers
            {
                TaskExecutor.AddTask(acc, new TrainTroops()
                {
                    ExecuteAt       = DateTime.Now.AddSeconds(2),
                    Troop           = Vill.Troops.TroopToTrain ?? Classificator.TroopsEnum.Hero,
                    Vill            = this.Vill,
                    HighSpeedServer = true
                });
            }

            // If FL is collapsed, expand it
            if (acc.AccInfo.ServerVersion == ServerVersionEnum.T4_4 ||
                flNode.Descendants("div").Any(x => x.HasClass("expandCollapse") && x.HasClass("collapsed")))
            {
                await DriverHelper.ExecuteScript(acc, $"Travian.Game.RaidList.toggleList({this.FL.Id});");

                // Update flNode!
                flNode = GetFlNode(acc.Wb.Html, acc.AccInfo.ServerVersion);
            }

            foreach (var farm in flNode.Descendants("tr").Where(x => x.HasClass("slotRow")))
            {
                //iReport2 = yellow swords, iReport3 = red swords, iReport1 = successful raid
                var img = farm.ChildNodes.FirstOrDefault(x => x.HasClass("lastRaid"))?.Descendants("img");

                //there has to be an image (we already have a report) and wrong raid style to not check this farmlist:
                if (img.Count() != 0 && (                                                                                            //no image -> no recent attack
                        (img.FirstOrDefault(x => x.HasClass("iReport3")) != null && this.FL.RaidStyle != RaidStyle.RaidLost) || //raid was lost and we don't have RaidLost raidstyle
                        (img.FirstOrDefault(x => x.HasClass("iReport2")) != null && (this.FL.RaidStyle == RaidStyle.RaidSuccessful)) //some casualities, but we only attack on successful
                        ))
                {
                    continue;
                }

                var checkbox = farm.Descendants("input").FirstOrDefault(x => x.HasClass("markSlot"));
                await DriverHelper.CheckById(acc, checkbox.Id, true, update : false);
            }

            await Task.Delay(AccountHelper.Delay() * 2);

            switch (acc.AccInfo.ServerVersion)
            {
            case ServerVersionEnum.T4_4:
                var sendFlScript = $"document.getElementById('{flNode.Id}').childNodes[1].submit()";
                wb.ExecuteScript(sendFlScript);
                break;

            case ServerVersionEnum.T4_5:
                var startRaid = flNode.Descendants("button").FirstOrDefault(x => x.HasClass("startButton"));
                acc.Wb.Driver.FindElementById(startRaid.Id).Click();
                break;
            }

            acc.Wb.Log($"FarmList '{this.FL.Name}' was sent");
            return(TaskRes.Executed);
        }
예제 #27
0
 public void clickOnTariffsAndPrices()
 {
     DriverHelper.SetText(tariffSelector, "");
     DriverHelper.ClickOnElement(tariffSelector);
 }
예제 #28
0
        private async void btnProceed_Click(object source, EventArgs ev)
        {
            btnProceed.Hide();
            btnFail.Hide();

            currentStage        += 1;
            progressStrip.Value += 25;

            DisplayMessage(currentStage);

            if (currentStage is Stage.Good)
            {
                statusIcon.Image = Properties.Resources.check;
                return;
            }
            if (currentStage is Stage.One)
            {
                statusIcon.Image = Properties.Resources.usb;

                await ESPConnection.GenerateInitialSignatureAsync();

                ESPConnection.OnConnect += ESPConnection_OnConnect;
                ESPConnection.BeginSearchingAsync();

                progressStrip.Mode = ProgressStrip.ControlMode.Marquee;
                return;
            }
            if (currentStage is Stage.Two)
            {
                ESPConnection.OnConnect -= ESPConnection_OnConnect;
                return;
            }
            if (currentStage is Stage.Three)
            {
                statusIcon.Image = Properties.Resources.network;

                progressStrip.Mode = ProgressStrip.ControlMode.Marquee;
                bool result = await DriverHelper.DownloadFileAsync(DriverHelper.ImageURI.DEAUTH, "image.bin");

                progressStrip.Mode = ProgressStrip.ControlMode.Regular;

                if (result)
                {
                    btnProceed_Click(source, ev);
                }
                else
                {
                    btnFail_Click(source, ev);
                }

                return;
            }
            if (currentStage is Stage.Four)
            {
                statusIcon.Image = Properties.Resources.icon_32;

                progressStrip.Mode = ProgressStrip.ControlMode.Marquee;
                await ESPFlasher.WipeDeviceAsync();

                bool result = await ESPFlasher.FlashDeviceAsync("image.bin");

                progressStrip.Mode = ProgressStrip.ControlMode.Regular;

                if (result)
                {
                    btnProceed_Click(source, ev);
                }
                else
                {
                    btnFail_Click(source, ev);
                }

                return;
            }
        }
예제 #29
0
 public OrderHistoryPage(IWebDriver driver)
 {
     Driver       = driver;
     driverHelper = new DriverHelper(Driver);
 }
예제 #30
0
 protected IWebDriver GetWebDriver(string browser)
 {
     return(DriverHelper.FactoryWebDriver(browser));
 }