Advertisement
Guest User

Untitled

a guest
Sep 7th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.50 KB | None | 0 0
  1.         private void init()
  2.         {
  3.  
  4.             webDriver.Navigate().GoToUrl("http://play.pokemonshowdown.com");
  5.  
  6.             IWebElement teamBuilder = webDriver.FindElement(By.CssSelector("div.menugroup:nth-child(2) > p:nth-child(1) > button:nth-child(1)"));
  7.             teamBuilder.Click();
  8.  
  9.             IWebElement newTeam = webDriver.FindElement(By.Name("newTop"));
  10.             newTeam.Click();
  11.  
  12.             IWebElement import = webDriver.FindElement(By.Name("import"));
  13.             import.Click();
  14.  
  15.             ReadOnlyCollection<IWebElement> teamimport = webDriver.FindElements(By.ClassName("textbox"));
  16.             foreach (IWebElement iwe in teamimport)
  17.             {
  18.                 string value = iwe.GetAttribute("value");
  19.                 if (value == null || value.Equals(""))
  20.                 {
  21.                     iwe.SendKeys(config.team);
  22.                     break;
  23.                 }
  24.             }
  25.  
  26.             IWebElement save = webDriver.FindElement(By.Name("saveImport"));
  27.             save.Click();
  28.  
  29.             Thread.Sleep(500);
  30.  
  31.             ReadOnlyCollection<IWebElement> selectTier = webDriver.FindElements(By.Name("format"));
  32.             foreach (IWebElement iwe in selectTier)
  33.             {
  34.                 if (iwe.Text.Contains("Select a format"))
  35.                 {
  36.                     iwe.Click();
  37.                     ReadOnlyCollection<IWebElement> selectFormat = webDriver.FindElements(By.Name("selectFormat"));
  38.                     foreach (IWebElement iwe2 in selectFormat)
  39.                     {
  40.                         if (iwe2.Text == "OU")
  41.                         {
  42.                             iwe2.Click();
  43.                             break;
  44.                         }
  45.                     }
  46.                     break;
  47.                 }
  48.             }
  49.  
  50.             Thread.Sleep(500);
  51.  
  52.             ReadOnlyCollection<IWebElement> home = webDriver.FindElements(By.ClassName("button"));
  53.             foreach (IWebElement iwe in home)
  54.             {
  55.                 if (iwe.Text.Contains("Home"))
  56.                 {
  57.                     iwe.Click();
  58.                     break;
  59.                 }
  60.             }
  61.  
  62.             IWebElement login = webDriver.FindElement(By.Name("login"));
  63.             login.Click();
  64.  
  65.             IWebElement username = webDriver.FindElement(By.CssSelector(".ps-popup > form:nth-child(1) > p:nth-child(1) > label:nth-child(1) > .textbox"));
  66.             username.SendKeys(config.user);
  67.  
  68.             IWebElement submit = webDriver.FindElement(By.CssSelector(".buttonbar > button:nth-child(1)"));
  69.             submit.Click();
  70.  
  71.             Thread.Sleep(1000);
  72.             IWebElement pass = webDriver.FindElement(By.CssSelector("body > div.ps-overlay > div > form > p:nth-child(4) > label > input"));
  73.             pass.SendKeys(config.password);
  74.  
  75.             login = webDriver.FindElement(By.CssSelector("p.buttonbar:nth-child(5) > button:nth-child(1)"));
  76.             login.Click();
  77.            
  78.             IWebElement musik = webDriver.FindElement(By.CssSelector("button.icon:nth-child(2)"));
  79.             musik.Click();
  80.             webDriver.FindElement(By.CssSelector(".ps-popup > p:nth-child(3) > label:nth-child(1) > input:nth-child(1)")).Click();
  81.             musik = webDriver.FindElement(By.CssSelector("button.icon:nth-child(2)"));
  82.             musik.Click();
  83.  
  84.             IJavaScriptExecutor js = webDriver as IJavaScriptExecutor;
  85.             js.ExecuteScript("window.app.tryJoinRoom(\"Pokefans\");");
  86.  
  87.             Thread.Sleep(1000);
  88.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement