Advertisement
ArCiGo

Exams

Mar 4th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. [TestMethod]
  2.         public void SeleniumElementLocationExam()
  3.         {
  4.             Driver.Navigate().GoToUrl("https://www.ultimateqa.com/simple-html-elements-for-automation/");
  5.  
  6.             // Click any radio button
  7.             Driver.FindElement(By.XPath("//*[@id='et-boc']/div/div[3]/div/div[1]/div[7]/div/div/div/form/input[1]")).Click();
  8.  
  9.             // Select one checkbox
  10.             Driver.FindElement(By.XPath("//*[@id='et-boc']/div/div[3]/div/div[1]/div[8]/div/div/div/form/input[1]")).Click();
  11.  
  12.             // Select Audi from the dropdown
  13.             Driver.FindElement(By.TagName("select")).Click();
  14.             Driver.FindElement(By.XPath("//*[@id='et-boc']/div/div[3]/div/div[1]/div[9]/div/div/div/select/option[4]")).Click();
  15.  
  16.             // Open Tab2 and asser it is openned
  17.             Driver.FindElement(By.XPath("//*[@id='et-boc']/div/div[3]/div/div[1]/div[10]/ul/li[2]")).Click();
  18.             Thread.Sleep(1000);
  19.             Assert.AreEqual("Tab 2 content", Driver.FindElement(By.XPath("//*[@id='et-boc']/div/div[3]/div/div[1]/div[10]/div/div[2]/div")).Text);
  20.  
  21.             // In the HTML table with ID, highlight one of the salary cells
  22.             HighlightElementUsingJavaScript(By.XPath("//*[@id='htmlTableId']/tbody/tr[2]/td[3]"));
  23.  
  24.             //Highlight the center section called "Highlight me", but you can only
  25.             //highlight the highest level div for that element. The top parent div.
  26.             //Hint, this is the class -
  27.             //et_pb_column et_pb_column_1_3  et_pb_column_10 et_pb_css_mix_blend_mode_passthrough
  28.             HighlightElementUsingJavaScript(By.CssSelector("#et-boc > div > div.et_pb_section.et_pb_section_4.et_section_regular > div > div.et_pb_column.et_pb_column_1_3.et_pb_column_10.et_pb_css_mix_blend_mode_passthrough"));
  29.             HighlightElementUsingJavaScript(
  30.                 By.XPath("//*[@class='et_pb_column et_pb_column_1_3 et_pb_column_10    et_pb_css_mix_blend_mode_passthrough']"));
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement