Ejemplo n.º 1
0
        public void login()
        {
            LoggedInStatus_Label.set_Text("trying to login to: {0}".format(MediaWikiUrl_TextBox.get_Text()))
            .textColor(Color.Black);
            var username = UserName_TextBox.get_Text();
            var password = Password_TextBox.get_Text();

            WikiApi.login(username, password).isFalse();

            if (WikiApi.loggedIn())
            {
                LoggedInStatus_Label.set_Text("Logged in as user: {0}".format(username))
                .textColor(Color.Green);
            }
            else
            {
                LoggedInStatus_Label.set_Text("Login failed for user {0}".format(username))
                .textColor(Color.Red);
            }
            SetWikiApi(WikiApi);
        }
Ejemplo n.º 2
0
    static void Main()
    {
        // Red text is for printing errors
        void RedMessage(string message)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(message);
            Console.ForegroundColor = ConsoleColor.White;
        }

        // Green text is for printing successes
        void GreenMessage(string message)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(message);
            Console.ForegroundColor = ConsoleColor.White;
        }

        RedMessage("Red Message Initialized");
        GreenMessage("Green Message Initialized");



        string      password = "******";
        string      username = "******";
        IWebDriver  driver   = new ChromeDriver();
        IWebElement UserName_TextBox;
        IWebElement Password_TextBox;
        IWebElement No_Save_Password;
        IWebElement GrandExchangeButton;

        GreenMessage("Initial_Setup Variables Successfully Initialized");

        void Initial_Setup()
        {
            try
            {
                driver.Navigate().GoToUrl("http://www.runescape.com/companion/comapp.ws");
                GreenMessage("Navigation Complete");
                Thread.Sleep(10000);
                GreenMessage("Wait for page to load");
                driver.SwitchTo().Frame(0);
                UserName_TextBox = driver.FindElement(By.Name("username"));
                UserName_TextBox.Click();
                UserName_TextBox.SendKeys(username);
                GreenMessage("Found Username Text Box");
                driver.SwitchTo().DefaultContent();
                driver.SwitchTo().Frame(0);
                Password_TextBox = driver.FindElement(By.Name("password"));
                Password_TextBox.Click();
                Password_TextBox.SendKeys(password);
                Password_TextBox.Submit();
                GreenMessage("Found Password Text Box");
                driver.SwitchTo().DefaultContent();
                driver.SwitchTo().Frame(0);
                GreenMessage("Wait for RS Authenticator");
                Thread.Sleep(20000);
                No_Save_Password = driver.FindElement(By.CssSelector("#modal > div > div > div > div.pill-wrap.double > a:nth-child(1)"));
                No_Save_Password.Click();
                GreenMessage("Don't save password clicked");
                Thread.Sleep(5000);
                GrandExchangeButton = driver.FindElement(By.CssSelector("#main-menu > div > nav > ul > li.grand-exchange > a"));
                GrandExchangeButton.Click();
                GreenMessage("Found GE Button on Main Menu");
                Thread.Sleep(5000);
            }
            catch (NoSuchElementException)
            {
                RedMessage("Initial Setup Failed");
            }
        }

        Initial_Setup();



        IWebElement Buy;
        IWebElement New_SearchBar;
        IWebElement New_MagicLogsButton;

        GreenMessage("Set_Price Variables Successfully Initialized");
        void Set_Price()
        {
            try
            {
                Buy = driver.FindElement(By.CssSelector("body > div.sliding-wrapper > div.ng-scope > section > div > ul > li:nth-child(1) > div > div > div.details.with-buttons > div > a:nth-child(1)"));
                Buy.Click();
                New_SearchBar = driver.FindElement(By.XPath("//*[@id=\"search\"]"));
                New_SearchBar.Click();
                New_SearchBar.SendKeys("Magic");
                Thread.Sleep(2000);
                New_SearchBar.SendKeys(" Logs");
                New_MagicLogsButton = driver.FindElement(By.CssSelector("body > div.sliding-wrapper > div.ng-scope > section > div.content.push-top-double.push-bottom-tiny.ng-scope > ul > li > a > div.details > span"));
                New_MagicLogsButton.Click();
            }
            catch (NoSuchElementException)
            {
                RedMessage("Set_Price Failed");
            }
        }

        /*
         * -------------------
         * MAIN LOOP -- MAIN LOOP
         * MAIN LOOP -- MAIN LOOP
         * MAIN LOOP -- MAIN LOOP
         * -------------------
         */



        /*
         * -------------------
         * MAIN LOOP -- MAIN LOOP
         * MAIN LOOP -- MAIN LOOP
         * MAIN LOOP -- MAIN LOOP
         * -------------------
         */
    }
Ejemplo n.º 3
0
        public ascx_MediaWiki_ConfigAndLogin buildGui(O2MediaWikiAPI wikiApi, Action <O2MediaWikiAPI> setWikiApi)
        {
            WikiApi    = wikiApi;
            SetWikiApi = setWikiApi;
            var controls           = this.add_1x1("Config", "Login Details", false);
            var config_Panel       = controls[0];
            var loginDetails_Panel = controls[1];

            //config_Panel
            TargetMediaWiki_ComboBox = config_Panel.add_Label("Target MediaWiki website", 12, 10)
                                       .append_Control <ComboBox>()
                                       .dropDownList()
                                       .onSelection <string>(loadMediaWikiDetails);

            MediaWikiUrl_TextBox = config_Panel.add_Label("MediaWiki Url:            ", 40, 10)
                                   .append_TextBox("");

            MediaWiki_API_php_TextBox = config_Panel.add_Label("MediaWiki api.php:     ", 60, 10)
                                        .append_TextBox("");
            MediaWiki_Index_php_TextBox = config_Panel.add_Label("MediaWiki index.php: ", 80, 10)
                                          .append_TextBox("");

            MediaWikiUrlCheck_Label = config_Panel.add_Link("Check MediaWiki Urls", 110, 128, checkMediaWikiUrls)
                                      .append_Label("")
                                      .autoSize();

            MediaWikiUrl_TextBox.align_Right(config_Panel).leftAdd(2).widthAdd(-7);
            MediaWiki_API_php_TextBox.align_Right(config_Panel).widthAdd(-5);
            MediaWiki_Index_php_TextBox.align_Right(config_Panel).widthAdd(-5);

            //loginDetails_Panel
            loginDetails_Panel.add_Label("A) Login using local config file:", 20, 10);
            SecretsFile_TextBox = loginDetails_Panel.add_TextBox(40, 102, false)
                                  .set_Text(defaultSecretsFolder.pathCombine(defaultSecretsFile))
                                  .onEnter(loadCredentials);


            Credential_ComboBox = loginDetails_Panel.add_ComboBox(60, 102).width(220).sorted();

            Credential_ComboBox.onSelection <ICredential>(loadCredentialDetails);
            loginDetails_Panel.add_Label("B) Login using username & password: "******"Username:"******"");
            Password_TextBox = loginDetails_Panel.add_Label("Password: "******"")
                               .isPasswordField();

            SecretsFile_TextBox.align_Right(loginDetails_Panel).widthAdd(-40);

            SecretsFile_TextBox.append_Control <Button>()
            .set_Text("...")
            .width(30)
            .heightAdd(-2)
            .anchor_TopRight()
            .onClick(() => {
                var file = this.askUserForFileToOpen(defaultSecretsFolder, "Xml Files | *.xml");
                if (file.valid())
                {
                    SecretsFile_TextBox.set_Text(file);
                    loadCredentials(file);
                }
            });;

            UserName_TextBox.width(200);
            Password_TextBox.width(200);

            LoggedInStatus_Label = Password_TextBox.append_Link("Login", login)
                                   .topAdd(5)
                                   .append_Label("")
                                   .autoSize();

            loadCredentials(SecretsFile_TextBox.get_Text());

            loadDefaultMediaWikiEngines();

            return(this);
        }
Ejemplo n.º 4
0
 public void loadCredentialDetails(ICredential credential)
 {
     UserName_TextBox.set_Text(credential.username());
     Password_TextBox.set_Text(credential.password());
 }