Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. using OpenQA.Selenium.Chrome;
  2. using OpenQA.Selenium.Interactions;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using OpenQA.Selenium.Support.UI;
  13. using OpenQA.Selenium;
  14. using System.Xml.Linq;
  15.  
  16. namespace SeleniumNo1
  17. {
  18. public partial class Form1 : Form
  19. {
  20.  
  21.  
  22. public Form1()
  23. {
  24. InitializeComponent();
  25.  
  26. }
  27.  
  28. ChromeDriver driver = new ChromeDriver();
  29. private void Button1_Click(object sender, EventArgs e)
  30. {
  31.  
  32. driver.Navigate().GoToUrl("https://poshmark.com/create-listing");
  33.  
  34. }
  35.  
  36. private void Button2_Click(object sender, EventArgs e)
  37. {
  38. var title = driver.FindElementByCssSelector("#content > div > div > div:nth-child(2) > section:nth-child(3) > div:nth-child(1) > div.col-x24.col-l20 > input");
  39.  
  40. if (title != null) ;
  41. {
  42. Actions actions = new Actions(driver);
  43. actions.MoveToElement(title);
  44. actions.Click();
  45. actions.SendKeys("Title controled by t3cho");
  46. actions.Build().Perform();
  47. }
  48.  
  49. var price = driver.FindElementByCssSelector("#content > div > div > div:nth-child(2) > section:nth-child(9) > div > div > div.col-x24.col-l20 > input.form__text.listing-editor__input--half.p--4");
  50.  
  51. if (price != null) ;
  52. {
  53. Actions actions = new Actions(driver);
  54. actions.MoveToElement(price);
  55. actions.Click();
  56. actions.SendKeys("22.50");
  57. actions.Build().Perform();
  58. }
  59.  
  60. WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
  61. IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
  62.  
  63. wait.Until(ExpectedConditions.
  64. ElementToBeClickable(By.XPath("//span[@data-et-name='category']/ancestor::div[contains(@class,'isting-editor__input--half')][1]")))
  65. .Click();
  66.  
  67. js.ExecuteScript("arguments[0].click()", driver.FindElement(By.LinkText("Accessories")));
  68. js.ExecuteScript("arguments[0].click()", driver.FindElement(By.LinkText("Glasses")));
  69.  
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement