Beispiel #1
0
        private bool MeetExists(string?link)
        {
            if (string.IsNullOrEmpty(link))
            {
                // throw new ArgumentNullException(nameof(link));
                return(false);
            }
            if (meetBot.State != MeetState.OutsideMeet &&
                meetBot.State != MeetState.InOverview)
            {
                logger.Error("Invalid state: {0}", meetBot.State);
                throw new InvalidOperationException("Invalid state");
            }

            try
            {
                meetBot.EnterMeetOverview(link);
                return(true);
            }
            catch (OpenQA.Selenium.WebDriverTimeoutException)
            {
                // Most likely
                if (link.Contains("/lookup/"))
                {
                    logger.Debug("No meet in lookup link (timeout)");
                    return(false);
                }

                throw;
            }
            catch (OpenQA.Selenium.StaleElementReferenceException)
            {
                if (link.Contains("/lookup/"))
                {
                    logger.Debug("No meet in lookup link (stale element)");
                    return(false);
                }

                throw;
            }
        }
Beispiel #2
0
        private static void MeetTest()
        {
            if (!File.Exists("config.json"))
            {
                MeetBot.CreateEmpty <Config>();
                Console.WriteLine("Created sample config.");
                return;
            }
            Config  config = JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.GetFullPath(".") + "/config.json"));
            MeetBot bot    = new MeetBot(config);

            try
            {
                bool loggedIn = bot.Login();
                if (!loggedIn)
                {
                    Console.WriteLine("Retrying login");
                    for (int i = 0; i < 3 && !loggedIn; i++)
                    {
                        loggedIn = bot.Login();
                    }
                    Console.WriteLine("Logged in: " + loggedIn);
                }
                bot.EnterMeetOverview("https://meet.google.com/rje-zpyi-jcg");
                Console.WriteLine(bot.PeopleInMeetOverview());
                bot.EnterMeet();
                Task wait = WaitFor(10);
                while (!wait.IsCompleted)
                {
                    Console.WriteLine(bot.PeopleInMeet());
                }
                bot.LeaveMeet();
            }
            finally
            {
                bot.Dispose();
            }
        }