public void TheXTest() { driver = new FirefoxDriver(); IJavaScriptExecutor js = driver as IJavaScriptExecutor; Login u = new Login(driver); string login1 = "guest"; u.get().login(login1, login1).click();//вход на сайт driver.FindElement(By.Id("sovzond_widget_SimpleButton_104")).Click(); Thread.Sleep(5000); IWebElement element = driver.FindElement(By.Id("sovzond_widget_SimpleButton_0")); var builder = new Actions(driver); builder.Click(element).Perform(); IList<IWebElement> el = driver.FindElements(By.ClassName("svzLayerManagerItem")); for (int n = 0; n < el.Count; n++) { if (el[0].Text != "Google") Assert.Fail("не найден Google"); if (el[4].Text != "Росреестр") Assert.Fail("не найден Росреестр"); if (el[5].Text != "OpenStreetMap") Assert.Fail("не найден OpenStreetMap"); if (el[6].Text != "Топооснова") Assert.Fail("не найден Топооснова"); } IWebElement element1 = driver.FindElement(By.Id("dijit_form_RadioButton_3")); builder.Click(element1).Perform(); Thread.Sleep(5000); string h= (string)js.ExecuteScript("return window.portal.stdmap.map.baseLayer.div.id.toString()"); }
public void ShouldAllowSelectingMultipleItems() { if (!IsNativeEventsEnabled || (!Platform.CurrentPlatform.IsPlatformType(PlatformType.Linux))) { Assert.Ignore("Skipping ShouldAllowSelectingMultipleItems: Only works with native events on Linux."); } driver.Url = selectableItemsPage; IWebElement reportingElement = driver.FindElement(By.Id("infodiv")); Assert.AreEqual("no info", reportingElement.Text); ReadOnlyCollection<IWebElement> listItems = driver.FindElements(By.TagName("li")); Actions actionBuider = new Actions(driver); IAction selectThreeItems = actionBuider.KeyDown(Keys.Control) .Click(listItems[1]) .Click(listItems[3]) .Click(listItems[5]) .KeyUp(Keys.Control).Build(); selectThreeItems.Perform(); Assert.AreEqual("#item2 #item4 #item6", reportingElement.Text); // Now click on another element, make sure that's the only one selected. actionBuider.Click(listItems[6]).Build().Perform(); Assert.AreEqual("#item7", reportingElement.Text); }
//an boundary constraint (to prevent the user from observing the future and the past(e.g. before 13.7Ga BC) ) public void MaxZoom(double lt, double rt, int zoom) { IWebElement buttonZoomOut = Driver.FindElement(By.Id("buttonZoomOut")); Actions actions = new Actions(Driver); (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + lt + "," + rt + ");"); actions.Build(); actions.MoveToElement(buttonZoomOut, 0, 0); for (int k = 0; k < zoom; k++) { actions.Click(); } actions.Release(); actions.Perform(); var afterZoom = (Driver as IJavaScriptExecutor). ExecuteScript("return $(\"#axis\").axis(\"getRange\");"); var afterzooml = Convert.ToDouble((afterZoom as Dictionary<string, object>)["left"]); var afterzoomr = Convert.ToDouble((afterZoom as Dictionary<string, object>)["right"]); Assert.IsTrue(afterzooml >= -13700000000.0); Assert.IsTrue(afterzoomr <= 0.0); }
public void ShouldAllowSelectingMultipleItems() { driver.Url = selectableItemsPage; IWebElement reportingElement = driver.FindElement(By.Id("infodiv")); Assert.AreEqual("no info", reportingElement.Text); ReadOnlyCollection<IWebElement> listItems = driver.FindElements(By.TagName("li")); Actions actionBuider = new Actions(driver); IAction selectThreeItems = actionBuider.KeyDown(Keys.Control) .Click(listItems[1]) .Click(listItems[3]) .Click(listItems[5]) .KeyUp(Keys.Control).Build(); selectThreeItems.Perform(); Assert.AreEqual("#item2 #item4 #item6", reportingElement.Text); // Now click on another element, make sure that's the only one selected. actionBuider.Click(listItems[6]).Build().Perform(); Assert.AreEqual("#item7", reportingElement.Text); }
public void ShouldAllowClickingOnFormElements() { if (!IsNativeEventsEnabled || (!Platform.CurrentPlatform.IsPlatformType(PlatformType.Linux))) { Assert.Ignore("Skipping ShouldAllowClickingOnFormElements: Only works with native events on Linux."); } driver.Url = formSelectionPage; ReadOnlyCollection<IWebElement> options = driver.FindElements(By.TagName("option")); Actions actionBuider = new Actions(driver); IAction selectThreeOptions = actionBuider.Click(options[1]) .KeyDown(Keys.Shift) .Click(options[2]) .Click(options[3]) .KeyUp(Keys.Shift).Build(); selectThreeOptions.Perform(); IWebElement showButton = driver.FindElement(By.Name("showselected")); showButton.Click(); IWebElement resultElement = driver.FindElement(By.Id("result")); Assert.AreEqual("roquefort parmigiano cheddar", resultElement.Text, "Should have picked the last three options."); }
private static void ClickCategoryTree(string category) { var expandNode = driver.FindElement(By.XPath("//div[@id='navigation']//span[text()='" + category + "']/parent::*/parent::*"), 5); Console.WriteLine(expandNode.GetAttribute("class")); var actions = new Actions(driver); actions.MoveToElement(expandNode); actions.Click(); actions.Perform(); }
/// <summary> /// Hover mouse above first element, then click on second element /// </summary> /// <param name="elementToHover">first IWebElement element</param> /// <param name="elementToClick">second IWebElement element</param> /// <returns></returns> public static IWebElement MouseHoverThenClick(this IWebElement elementToHover, IWebElement elementToClick) { OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(Browser.Driver); action.MoveToElement(elementToHover); action.MoveToElement(elementToClick); action.Click(elementToClick); action.Build().Perform(); return(elementToHover); }
private void OpenBaseLayers() { driver.FindElement(By.CssSelector(locationSlideMenu)).Click(); IWebElement elementBaseLayer = driver.FindElement(By.CssSelector(locationBaseLayers)); var builderBaseLayers = new Actions(driver); System.Threading.Thread.Sleep(1000); builderBaseLayers.Click(elementBaseLayer).Perform(); System.Threading.Thread.Sleep(1000); }
/// <summary> /// Click method /// </summary> /// <param name="element">element which is do click</param> internal static void Click(IWebElement element) { try { OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(webDriver); action.Click(element).Perform(); } catch (WebDriverException) { Wait(TimeSpan.FromSeconds(15)); } }
public void KeyUpAndKeyDown() { var list = this.MainWindow.FindElement(By.Id("TextListBox")); var items = list.FindElements(By.ClassName("ListBoxItem")); var first = items.First(); var random = items.ElementAt(3); var actions = new Actions(this.Driver); actions.Click(first).KeyDown(Keys.Shift).Click(random).KeyUp(Keys.Shift).Perform(); var selectedItemsCount = list.FindElements(By.ClassName("ListBoxItem")).Count(item => item.Selected); Assert.AreEqual(4, selectedItemsCount); }
public string fileupload(IWebDriver driver, string pageData) { try { OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(driver); actions.MoveToElement(driver.FindElement(By.XPath("//div[@class='k-button k-upload-button']"))); actions.Click(); actions.Build().Perform(); Thread.Sleep(24000); return("Pass"); } catch (Exception ex) { return(ex.Message); } }
public void TestRowSelectionUsingControlKey() { var tableRows = driver.FindElements(By.XPath("//table[@class='iceDatTbl']/tbody/tr")); //Select second and fourth row from table using Control Key. //Row Index start at 0 Actions builder = new Actions(driver); builder.Click(tableRows[1]) .KeyDown(Keys.Control) .Click(tableRows[3]) .KeyUp(Keys.Control) .Build().Perform(); //Verify Selected Row table shows two rows selected var rows = driver.FindElements(By.XPath("//div[@class='icePnlGrp exampleBox']/table[@class='iceDatTbl']/tbody/tr")); Assert.AreEqual(2,rows.Count); }
public static void CreateInd(TitlesList.EnumAdminLeftBar pageName) { // ReadOnlyCollection<IWebElement> topBarElements; Driver.Wait(2); /*Array enumNamesTopBar = Enum.GetNames(typeof(TitlesList.EnumTitlesTopBar)); int pos = Array.IndexOf(enumNamesTopBar, pageName); if (pos > -1) { topBarElements = Driver.Instance.FindElements(By.ClassName("topbar")); } else { topBarElements = Driver.Instance.FindElements(By.ClassName("admin-left-navigation-panel")); }*/ /* var barElements = Driver.Instance.FindElements(By.ClassName("admin-inner-page-content")); int valueOfEnum = (int)pageName; // string pageNameString = Enum.GetName(typeof(TitlesList.EnumAdminLeftBar), valueOfEnum).ToString(); string pageNameString = pageName.ToString(); pageNameString = pageNameString.Replace('_', ' '); foreach (var row in barElements) { ReadOnlyCollection<IWebElement> links = null; // Driver.NoWait(() => links = row.FindElements(By.LinkText(pageName))); links = row.FindElements(By.PartialLinkText("Add new")); if (links.Count > 0) { links[0].Click(); } }*/ var link1 = Driver.Instance.FindElement(By.LinkText("Add new")); link1.Click(); Driver.Wait(2); var inputs = Driver.Instance.FindElements(By.TagName("input")); inputs[0].SendKeys("Test Title"); inputs[1].SendKeys("Test Id"); var inputs1 = Driver.Instance.FindElement(By.CssSelector("body>div:nth-child(1)>section >div.admin-pages-content>div.admin-inner-page-content>div>form>fieldset>div:nth-child(2)>div:nth-child(8)>span.k-widget.k-dropdown.k-header.ng-pristine.ng-valid.ng-touched>span>span.k-input.ng-scope")); Actions action = new Actions(Driver.Instance); action.MoveToElement(inputs1); action.Perform(); action.Click(); action.Perform(); }
public void TestRowSelectionUsingShiftKey() { var tableRows = driver.FindElements(By.XPath("//table[@class='iceDatTbl']/tbody/tr")); //Select first row to fourth row from Table using Shift Key //Row Index start at 0 Actions builder = new Actions(driver); builder.Click(tableRows[0]) .KeyDown(Keys.Shift) .Click(tableRows[1]) .Click(tableRows[2]) .Click(tableRows[3]) .KeyUp(Keys.Shift) .Build().Perform(); var rows = driver.FindElements(By.XPath("//div[@class='icePnlGrp exampleBox']/table[@class='iceDatTbl']/tbody/tr")); Assert.AreEqual(4,rows.Count); }
public void ShouldAllowClickingOnFormElements() { driver.Url = formSelectionPage; ReadOnlyCollection<IWebElement> options = driver.FindElements(By.TagName("option")); Actions actionBuider = new Actions(driver); IAction selectThreeOptions = actionBuider.Click(options[1]) .KeyDown(Keys.Shift) .Click(options[2]) .Click(options[3]) .KeyUp(Keys.Shift).Build(); selectThreeOptions.Perform(); IWebElement showButton = driver.FindElement(By.Name("showselected")); showButton.Click(); IWebElement resultElement = driver.FindElement(By.Id("result")); Assert.AreEqual("roquefort parmigiano cheddar", resultElement.Text, "Should have picked the last three options."); }
public void PlainClickingOnMultiSelectionList() { driver.Url = formSelectionPage; ReadOnlyCollection <IWebElement> options = driver.FindElements(By.TagName("option")); Actions actionBuider = new Actions(driver); IAction selectThreeOptions = actionBuider.Click(options[1]) .Click(options[2]) .Click(options[3]).Build(); selectThreeOptions.Perform(); IWebElement showButton = driver.FindElement(By.Name("showselected")); showButton.Click(); IWebElement resultElement = driver.FindElement(By.Id("result")); Assert.AreEqual("cheddar", resultElement.Text, "Should have picked the third option only."); }
public void ShiftClickingOnMultiSelectionList() { driver.Url = formSelectionPage; ReadOnlyCollection <IWebElement> options = driver.FindElements(By.TagName("option")); Actions actionBuider = new Actions(driver); IAction selectThreeOptions = actionBuider.Click(options[1]) .KeyDown(Keys.Shift) .Click(options[2]) .Click(options[3]) .KeyUp(Keys.Shift).Build(); selectThreeOptions.Perform(); IWebElement showButton = driver.FindElement(By.Name("showselected")); showButton.Click(); IWebElement resultElement = driver.FindElement(By.Id("result")); Assert.AreEqual("roquefort parmigiano cheddar", resultElement.Text, "Should have picked the last three options."); }
static void OpenGlobalMenu() { var link = driver.FindElement(By.XPath("//div[@id='globalMenuContainer']//a"), 5); Actions actions2 = new Actions(driver); actions2.MoveToElement(link); actions2.Click().Perform(); //var contentTypeTab = driver.FindElement(By.LinkText("Content Type")); //actions2.MoveToElement(contentTypeTab); //actions2.Click().Perform(); }
/// <summary> /// Performs the click. /// </summary> /// <param name="element">Element.</param> public void PerformClick(IWebElement element) { Actions act = new Actions(Factory.Instance); Console.WriteLine("PerformClick '{0}'", element.Text); act.Click(element); act.Perform(); }
public void ShouldNotMoveToANullLocator() { driver.Url = javascriptPage; Actions actionProvider = new Actions(driver); try { IAction contextClick = actionProvider.MoveToElement(null).Build(); contextClick.Perform(); Assert.Fail("Shouldn't be allowed to click on null element."); } catch (ArgumentException) { // Expected. } try { actionProvider.Click().Build().Perform(); Assert.Fail("Shouldn't be allowed to click without a context."); } catch (Exception) { // expected } }
/// <summary> /// Scroll to an element using JS and click it; necessary for Chrome WebDriver for certain elements /// </summary> /// <param name="element"></param> public static void ScrollAndClick(this IWebElement element) { Actions act = new Actions(Browser.Driver); IJavaScriptExecutor js = Browser.Driver as IJavaScriptExecutor; js.ExecuteScript(string.Format("window.scrollTo(0, {0});", element.Location.Y)); act.Click(element).Perform(); }
public IMouseActions Click() { actions.Click(); return(this); }
//inner zoom not deeper 4 decimal fraction digits public void MinZoomNoMoreFourSigns(double x1, double x2, int zoom) { IWebElement buttonZoomIn = Driver.FindElement(By.Id("buttonZoomIn")); Actions actions = new Actions(Driver); (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + x1 + "," + x2 + ");"); actions.Build(); actions.MoveToElement(buttonZoomIn, 0, 0); for (int k = 0; k < zoom; k++) { actions.Click(); } actions.Release(); actions.Perform(); var afterZoom = (Driver as IJavaScriptExecutor). ExecuteScript("return $(\"#axis\").axis(\"getRange\");"); var afterzooml = Convert.ToDouble((afterZoom as Dictionary<string, object>)["left"]); var afterzoomr = Convert.ToDouble((afterZoom as Dictionary<string, object>)["right"]); double aftern = afterzoomr - afterzooml; int decimaldigitsl = Counter(afterzooml); int decimaldigitsr = Counter(afterzoomr); int decimaldigitsn = Counter(aftern); Assert.IsTrue(decimaldigitsl <= 4 && decimaldigitsr <= 4); Assert.IsTrue(decimaldigitsn <= 4); }
public void MouseClick(IWebElement element) { Console.WriteLine("Click the mouse on the element"); var builder = new Actions(Driver); builder.Click(element).Perform(); }
static void ToggleNavigationPan() { var span = driver.FindElement(By.XPath("//div[@id='applicationContainer']//div[@id='/episerver/commerce/catalog_rootContainer']//div[@class='dijit epi-globalToolbar dijitToolbar']//span[@class='dijitReset dijitInline dijitButtonNode']"), 5); var actionPan = new Actions(driver); actionPan.MoveToElement(span); actionPan.Click(); actionPan.Perform(); var pin = driver.FindElement( By.XPath( "//div[@id='navigation']//div[@class='epi-pinnableToolbar']//div[@class='epi-toolbarGroup epi-toolbarTrailing']/span[2]//span[@class='dijitReset dijitInline dijitButtonNode']"), 5); var actionPin = new Actions(driver); actionPin.MoveToElement(pin); actionPin.Click(); actionPin.Perform(); }
public void TestZoomOutMarker() { GoToUrl(); IWebElement buttonHelper = Driver.FindElement(By.Id("buttonHelper")); IWebElement buttonZoomMarkerOut = Driver.FindElement(By.Id("buttonZoomMarkerOut")); Actions actions = new Actions(Driver); actions.Build(); actions.MoveToElement(buttonHelper, 0, 0); actions.Click(); var afterHelper = (Driver as IJavaScriptExecutor). ExecuteScript("return $(\"#axis\").axis(\"getRange\");"); var ahl = Convert.ToDouble((afterHelper as Dictionary<string, object>)["left"]); var ahr = Convert.ToDouble((afterHelper as Dictionary<string, object>)["right"]); double z1 = ahr - ahl; actions.MoveToElement(buttonZoomMarkerOut, 0, 0); actions.Click(); actions.Release(); actions.Perform(); var afterZoomOutMarker = (Driver as IJavaScriptExecutor). ExecuteScript("return $(\"#axis\").axis(\"getRange\");"); var azml = Convert.ToDouble((afterZoomOutMarker as Dictionary<string, object>)["left"]); var azmr = Convert.ToDouble((afterZoomOutMarker as Dictionary<string, object>)["right"]); double z2 = azmr - azml; Assert.IsTrue(ahl > azml && ahr < azmr && z1 < z2); }
// zoom out public void ZoomOut(double l, double r) { IWebElement buttonZoomOut = Driver.FindElement(By.Id("buttonZoomOut")); Actions actions = new Actions(Driver); (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + l + "," + r + ");"); var beforeZoomOut = (Driver as IJavaScriptExecutor). ExecuteScript("return $(\"#axis\").axis(\"getRange\");"); var bzl = Convert.ToDouble((beforeZoomOut as Dictionary<string, object>)["left"]); var bzr = Convert.ToDouble((beforeZoomOut as Dictionary<string, object>)["right"]); double z1 = bzr - bzl; actions.Build(); actions.MoveToElement(buttonZoomOut, 0, 0); actions.Click(); actions.Release(); actions.Perform(); var afterZoomOut = (Driver as IJavaScriptExecutor). ExecuteScript("return $(\"#axis\").axis(\"getRange\");"); var azl = Convert.ToDouble((afterZoomOut as Dictionary<string, object>)["left"]); var azr = Convert.ToDouble((afterZoomOut as Dictionary<string, object>)["right"]); double z2 = azr - azl; if (z1 <= OneDay(134, 5, 2, 4)) { Assert.IsTrue(z1 <= z2); } else { Assert.IsTrue(z1 < z2); } }
////inner zoom not deeper 1 day public void MinZoomDay(int sYear, int sMonth, int sDay, int eYear, int eMonth, int eDay, double l, int zoom) { IWebElement buttonZoomIn = Driver.FindElement(By.Id("buttonZoomIn")); Actions actions = new Actions(Driver); var d = (Driver as IJavaScriptExecutor).ExecuteScript ("return $(\"#axis\").axis(\"getYearsBetweenDates\"," + sYear + "," + sMonth + "," + sDay + "," + eYear + "," + eMonth + "," + eDay + ");"); (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setPresent\"," + sYear + "," + sMonth + "," + sDay + ");"); double betwenDays = Convert.ToDouble(d); double r = betwenDays + l; (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + l + "," + r + ");"); actions.Build(); actions.MoveToElement(buttonZoomIn, 0, 0); for (int k = 0; k < zoom; k++) { actions.Click(); } actions.Release(); actions.Perform(); var afterZoom = (Driver as IJavaScriptExecutor). ExecuteScript("return $(\"#axis\").axis(\"getRange\");"); var azl = Convert.ToDouble((afterZoom as Dictionary<string, object>)["left"]); var azr = Convert.ToDouble((afterZoom as Dictionary<string, object>)["right"]); double z = azr - azl; double d1 = OneDay(1233, 3, 4, 5); double d2 = OneDay(23, 8, 17, 18); double d3 = OneDay(2005, 11, 1, 2); Assert.IsTrue(z >= d1); Assert.IsTrue(z >= d2); Assert.IsTrue(z >= d3); }
static void NavigateToNewCatalogUI() { OpenGlobalMenu(); Thread.Sleep(2000); if (NavigationDropDownIsActive()) { // Open drop down menu driver.FindElement( By.XPath( "//div[@id='globalMenuContainer']/div[@class='epi-navigation-accordioncontainer']/div[@class='epi-navigation-container1']/a[@href='#global_more_sub']"), 5) .Click(); driver.FindElement( By.XPath( "div[@class, 'epi-navigation-more-items-wrapper epi-contextMenu']/a[@href='#global_Commerce_sub']"), 5) .Click(); OpenGlobalMenu(); } else { var commerceLink = driver.FindElement( By.XPath( "//div[@id='globalMenuContainer']//div[contains(@class, 'epi-navigation-accordioncontainer')]//div[@class='epi-navigation-container1']//span[text()='Commerce']"), 5); var actions = new Actions(driver); actions.MoveToElement(commerceLink); actions.Click(); actions.Perform(); } //epi-navigation-container2 div //global_Commerce_sub ul var catalogLink = driver.FindElement( By.XPath("//div[@id='globalMenuContainer']//div[contains(@class, 'epi-navigation-accordioncontainer')]//div[@class='epi-navigation-container2']//ul[@id='global_Commerce_sub']//a[text()='Catalog']"), 5); var actionCatalog = new Actions(driver); actionCatalog.MoveToElement(catalogLink); actionCatalog.Click(); actionCatalog.Perform(); }
static void Main(string[] args) { driver = new ChromeDriver(); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl(baseURL + "/"); Login(); Thread.Sleep(2000); driver.FindElement(By.Id("epi-quickNavigator-clickHandler")).Click(); Thread.Sleep(1000); driver.FindElement(By.XPath("//ul[@id='epi-quickNavigator']//li[@class='epi-quickNavigator-dropdown']//ul[@id='epi-quickNavigator-menu']//a[text()='CMS Edit']")).Click(); Thread.Sleep(2000); NavigateToNewCatalogUI(); Thread.Sleep(2000); ToggleNavigationPan(); //ExpandCatalogRoot(); ExpandCategory( new string[]{ "Catalog Root", "Departmental Catalog", "Departments", "Media", "Music", }); HoverCategoryTree("Music-Soundtrack"); Click_Tab_AllProperties("Assets"); //PlaceOrder(); //var ul = driver.FindElement(By.Id("epi-quickNavigator-menu")); //Console.WriteLine(ul.GetAttribute("style")); //var links = ul.FindElements(By.TagName("a")); //var li = ul.FindElements(By.TagName("li")); //foreach (var link in links) //{ // Console.WriteLine(link.Text); //} //var dashBoardLink = links.First(element => element.Text == "Dashboard"); //Console.WriteLine(dashBoardLink.Location); //var cmsEditLink = links.First(element => element.Text == "CMS Edit"); //Console.WriteLine(cmsEditLink.Location); //OpenGlobalMenu(); return; var span = driver.FindElement(By.Id("uniqName_26_46")); Console.WriteLine(span != null); var sParent = span.FindElement(By.XPath("./parent::*")); if (sParent != null) { Console.WriteLine("hjeheheheh"); Console.WriteLine(sParent.GetAttribute("data-dojo-attach-event")); Actions actions = new Actions(driver); actions.MoveToElement(sParent);//.Build().Perform(); actions.Click().Perform(); var pin = driver.FindElement(By.Id("dijit_form_ToggleButton_6")); var pPin = pin.FindElement(By.XPath("./parent::*")); if (pPin != null) { Console.WriteLine(pPin.GetAttribute("data-dojo-attach-event")); actions.MoveToElement(pPin);//.Build().Perform(); actions.Click().Perform(); } } var treeDiv = driver.FindElement(By.Id("navigation")); if (treeDiv != null) { Actions actions1 = new Actions(driver); Console.WriteLine("left tree can be recorgnied"); var homePageNode = treeDiv.FindElement(By.XPath("//span[contains(@title, '2526')]")); actions1.MoveToElement(homePageNode.FindElement(By.XPath("./parent::*"))); actions1.Click().Perform(); //Create content var createButton = driver.FindElement(By.XPath("//span[contains(@title, 'Create content')]")); actions1.MoveToElement(createButton.FindElement(By.XPath("./parent::*"))); actions1.Click().Perform(); var newPageRow = driver.FindElement(By.Id("uniqName_26_47")); actions1.MoveToElement(newPageRow); actions1.Click().Perform(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); //data-dojo-attach-point="namePanel" var namePanelDiv = driver.FindElement(By.XPath("//div[contains(@data-dojo-attach-point, 'namePanel')]//div[contains(@class, 'dijitReset dijitInputField dijitInputContainer')]")); if (namePanelDiv != null) { //dijitReset dijitInputField dijitInputContainer var newPageInput = namePanelDiv.FindElement(By.TagName("input")); Console.WriteLine(newPageInput.GetAttribute("id")); actions1.MoveToElement(newPageInput); actions1.Click().Perform(); actions1.SendKeys(Keys.Backspace); actions1.SendKeys(Keys.Backspace); actions1.SendKeys(Keys.Backspace); actions1.SendKeys(Keys.Backspace); actions1.SendKeys(Keys.Backspace); actions1.SendKeys(Keys.Backspace); actions1.SendKeys(Keys.Backspace); actions1.SendKeys(Keys.Backspace); actions1.SendKeys("TestPage"); var homePage = driver.FindElement(By.XPath("//h3[contains(text(), 'Home Page')]")).FindElement(By.XPath("./parent::*")); actions1.MoveToElement(homePage); actions1.Click().Perform(); Thread.Sleep(5000); var tiny = driver.FindElement(By.ClassName("epi-overlay-bracket")); actions1.MoveToElement(tiny); actions1.Click().Perform(); Thread.Sleep(3000); var winHandleBefore = driver.CurrentWindowHandle; driver.SwitchTo().Frame("uniqName_110_0_editorFrame_ifr"); var p = driver.FindElement(By.Id("tinymce")).FindElement(By.TagName("p")); actions1.MoveToElement(p); actions1.SendKeys("skdfj sjlfdkjsl djfklj sldfkj").Perform(); Thread.Sleep(3000); driver.SwitchTo().Window(winHandleBefore); //dijit dijitReset dijitInline epi-mediumButton epi-modeButton dijitToggleButton var toggleButton = driver.FindElement( By.XPath( "//span[contains(@class, 'dijit dijitReset dijitInline epi-mediumButton epi-modeButton dijitToggleButton')]")).FindElement(By.TagName("span")); actions1.MoveToElement(toggleButton); actions1.Click().Perform(); Thread.Sleep(3000); var form = driver.FindElement(By.XPath("//form[@class='epi-formArea']")); var div = form.FindElement(By.TagName("div")); Console.WriteLine(div.GetAttribute("class")); var div1 = div.FindElement(By.XPath("//div[@class='dijitTabPaneWrapper dijitTabContainerTop-container']")); Console.WriteLine(div1.GetAttribute("aria-labelledby")); var ul = div1.FindElement(By.XPath(".//ul")); var lis = ul.FindElements(By.XPath(".//li")); Console.WriteLine("li count: " + lis.Count.ToString()); var label = lis[0].FindElement(By.XPath(".//label")); Console.WriteLine(lis[1].FindElement(By.XPath(".//label[contains(.,'StringField')]")).GetAttribute("for")); Console.WriteLine("for: " + label.GetAttribute("for")); var labelChild = label.FindElements(By.XPath("*")); Console.WriteLine("label child count: " + labelChild.Count.ToString()); //var label = driver.FindElement(By.XPath("//label[contains(text(), 'PayPalPaymentPage')]")); //if (label != null) //{ // Console.WriteLine("PayPalPaymentPage label found"); //} } //span[contains(@title, 'Home Page')] // //div[contains(@class, 'v-table-body')] } // driver.Quit(); //driver.FindElement(By.XPath("//span[@id='uniqName_26_46']/span")).Click(); //driver.FindElement(By.XPath("//span[@id='uniqName_26_46']/span")).Click(); //uniqName_26_46 //IWebElement elem = driver.FindElement(By.XPath(".//*[@id='epi-quickNavigator-menu']/a[text()='CMS Edit']")); //Actions actions = new Actions(driver); //actions.MoveToElement(elem).Build().Perform(); //actions.MoveToElement(cmsEditLink).Build().Perform(); //cmsEditLink.Click(); //actions.Click().Perform(); //Console.ReadKey(); }
private static void ExpandCategory(string category) { var expandNode = driver.FindElement(By.XPath("//div[@id='navigation']//span[text()='" + category + "']//preceding-sibling::span[contains(@class, 'dijitTreeExpando')]"), 5); if (expandNode.GetAttribute("class").Contains("dijitTreeExpandoClosed")) { var actions = new Actions(driver); actions.MoveToElement(expandNode); actions.Click(); actions.Perform(); Thread.Sleep(500); while (driver.FindElement(By.XPath("//div[@id='navigation']//span[text()='" + category + "']//preceding-sibling::span[contains(@class, 'dijitTreeExpando')]"), 5).GetAttribute("class").Contains("dijitTreeExpandoLoading")) { Thread.Sleep(500); } } }
private static void ExpandCatalogRoot() { var expandNode = driver.FindElement(By.XPath("//div[@id='navigation']//span[text()='Catalog Root']//preceding-sibling::span[contains(@class, 'dijitTreeExpando')]"), 5); if (expandNode.GetAttribute("class").Contains("dijitTreeExpandoClosed")) { var actions = new Actions(driver); actions.MoveToElement(expandNode); actions.Click(); actions.Perform(); } }
public void TestMouse_MoveAndClick_Rectangle() { GoToUrl(); IWebElement vc = Driver.FindElement(By.Id("vc")); IWebElement button = Driver.FindElement(By.Id("button")); var rectCenterX = Convert.ToDouble((Driver as IJavaScriptExecutor).ExecuteScript("return rectCenterX;")); var scale = Convert.ToDouble((Driver as IJavaScriptExecutor).ExecuteScript("return scale;")); Actions actions = new Actions(Driver); // building mouse moves on the virtual canvas element actions.Build(); actions.MoveToElement(vc, vc.Size.Width / 2 + (int)(rectCenterX / scale), vc.Size.Height / 2); actions.Click(); actions.MoveToElement(button, 0, 0); actions.Release(); actions.Perform(); var res = (Driver as IJavaScriptExecutor).ExecuteScript("return isRectMovedIn;"); Assert.AreNotEqual(0.0, Convert.ToDouble(res)); res = (Driver as IJavaScriptExecutor).ExecuteScript("return isRectMovedOut;"); Assert.AreNotEqual(0.0, Convert.ToDouble(res)); res = (Driver as IJavaScriptExecutor).ExecuteScript("return isRectClicked;"); Assert.AreNotEqual(0.0, Convert.ToDouble(res)); }
public void Click() { EnsureFocus(); Actions action = new Actions(this.Driver); action.Click(); action.Perform(); }