Beispiel #1
0
 private static async Task AcceptAllCookie()
 {
     try
     {
         // ReSharper disable StringLiteralTypo
         await PptrUtils.WaitAndClick("#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll");
     }
     catch (Exception)
     {
         // ignored
     }
 }
        public static async Task Run()
        {
            foreach (string profileName in GenshinSharedUtils.ProfileNames)
            {
                try
                {
                    Console.WriteLine("Profile: " + profileName);

                    var profilePath = Paths.GetChromiumUserDataDir(profileName);
                    PptrUtils.ProfilePath = profilePath;
                    _page = PptrUtils.Page;

                    const string url = "https://webstatic-sea.mihoyo.com/ys/event/e20211203-album/index.html";
                    await _page.GoToAsync(url, WaitUntilNavigation.Load);

                    if (!await GenshinSharedUtils.CheckAuth(_page))
                    {
                        throw new Exception("Auth problem!");
                    }

                    Thread.Sleep(30000); /* wait animation */

                    await PptrUtils.WaitAndClick("div.main-button.main-button__left", PptrUtils.LongSelectorAwaiter);

                    Thread.Sleep(3000);

                    ElementHandle[] dayDivs = (await _page.QuerySelectorAllAsync("div"))
                                              .Where(div => div.EvaluateFunctionAsync <string>("e => e.className").Result.Contains("day-list-item"))
                                              .ToArray();

                    foreach (ElementHandle dayDiv in dayDivs)
                    {
                        await dayDiv.ClickAsync();

                        Thread.Sleep(1000);

                        ElementHandle[] getDivs = (await _page.QuerySelectorAllAsync("div"))
                                                  .Where(div => div.EvaluateFunctionAsync <string>("e => e.innerHTML").Result == "Получить")
                                                  .ToArray();

                        foreach (ElementHandle getDiv in getDivs)
                        {
                            await getDiv.ClickAsync();

                            Thread.Sleep(1000);
                        }
                    }

                    _page.QuerySelectorAsync("div[class^='components-topNav-assets-__topNav_---close-btn---']").Result
                    .ClickAsync().GetAwaiter().GetResult();
                    Thread.Sleep(3000);

                    await PptrUtils.WaitAndClick("div.main-button.main-button__right", PptrUtils.LongSelectorAwaiter);

                    Thread.Sleep(3000);

                    (await _page.QuerySelectorAllAsync("div"))
                    .FirstOrDefault(div => div.EvaluateFunctionAsync <string>("e => e.innerHTML").Result == "Отмена")
                    ?.ClickAsync().GetAwaiter().GetResult();
                    Thread.Sleep(1000);

                    await PptrUtils.WaitAndClick("div.button-spot__progress", PptrUtils.LongSelectorAwaiter);

                    Thread.Sleep(3000);

                    ElementHandle[] awardIcons = await _page.QuerySelectorAllAsync("div[class^='components-award-assets-__award_---icon---'");

                    foreach (ElementHandle awardIcon in awardIcons)
                    {
                        await awardIcon.ClickAsync();

                        Thread.Sleep(1000);

                        //grab award
                        (await _page.QuerySelectorAllAsync("div"))
                        .FirstOrDefault(div => div.EvaluateFunctionAsync <string>("e => e.innerHTML").Result == "Получить")
                        ?.ClickAsync().GetAwaiter().GetResult();
                        Thread.Sleep(1000);
                        await PptrUtils.ClickIfExists("div[class^='components-result-assets-__result_---click-close---'");
                    }

                    Console.WriteLine("debug");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                finally
                {
                    await PptrUtils.CloseAsync();
                }
            }
        }
Beispiel #3
0
        private static async Task Order()
        {
            await PptrUtils.WaitAndClick("form[name='orderForm'] button[type='submit']");

            await _page.WaitForSelectorAsync("h1.order__title.order__title--success", PptrUtils.ShortSelectorAwaiter);
        }