void PerformLogIn() { By usernameInputSelector = By.Id("input_username"); By passwordInputSelector = By.Id("input_password"); By captchaInputSelector = By.Id("input_captcha"); By rememberLoginChecboxSelector = By.Id("remember_login"); By logInButtonSelector = By.XPath(@"//*[@id='login_btn_signin']/button"); if (webProcessor.IsElementVisible(captchaInputSelector)) { ThrowLogInException("Captcha input required"); } webProcessor.SetText(usernameInputSelector, botSettings.SteamUsername); webProcessor.SetText(passwordInputSelector, botSettings.SteamPassword); if (webProcessor.IsElementVisible(rememberLoginChecboxSelector)) { webProcessor.UpdateCheckbox(rememberLoginChecboxSelector, true); } webProcessor.Click(logInButtonSelector); InputSteamGuardCodeIfRequired(); }
string GetStreamUrlFromPageSource() { By startStreamButtonSelector = By.Id("start-video"); webProcessor.Click(startStreamButtonSelector); string html = webProcessor.GetPageSource(); return(Regex.Match(html, StreamUrlPattern).Groups[1].Value); }
void RemoveLicense(string removalScript) { By licensesTableSelector = By.ClassName("account_table"); By confirmationButtonSelector = By.XPath($"//*[contains(@class,'btn_green_white_innerfade')]"); webProcessor.WaitForElementToBeVisible(licensesTableSelector); webProcessor.ExecuteScript(removalScript); webProcessor.Click(confirmationButtonSelector); webProcessor.Refresh(); webProcessor.WaitForElementToBeInvisible(confirmationButtonSelector); webProcessor.WaitForElementToBeInvisible(licensesTableSelector); webProcessor.WaitForElementToBeVisible(licensesTableSelector); }
void ActivateKey(string key) { logger.Info( MyOperation.KeyActivation, OperationStatus.Started, new LogInfo(MyLogInfoKey.KeyCode, key)); By keyInputSelector = By.Id("product_key"); By keyActivationButtonSelector = By.Id("register_btn"); By agreementCheckboxSelector = By.Id("accept_ssa"); By errorSelector = By.Id("error_display"); By receiptSelector = By.Id("receipt_form"); By productNameSelector = By.ClassName("registerkey_lineitem"); if (!webProcessor.IsElementVisible(keyInputSelector)) { webProcessor.GoToUrl(KeyActivationUrl); } webProcessor.SetText(keyInputSelector, key); webProcessor.UpdateCheckbox(agreementCheckboxSelector, true); webProcessor.Click(keyActivationButtonSelector); webProcessor.WaitForAnyElementToBeVisible(errorSelector, receiptSelector); if (webProcessor.IsElementVisible(errorSelector)) { string errorMessage = webProcessor.GetText(errorSelector); HandleActivationError(key, errorMessage); return; } string productName = webProcessor.GetText(productNameSelector); keyHandler.MarkKeyAsActivated(key, productName); logger.Debug( MyOperation.KeyActivation, OperationStatus.Success, new LogInfo(MyLogInfoKey.KeyCode, key)); }