本文整理汇总了C#中OpenQA.Selenium.Interactions.Actions.Click方法的典型用法代码示例。如果您正苦于以下问题:C# Actions.Click方法的具体用法?C# Actions.Click怎么用?C# Actions.Click使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Interactions.Actions
的用法示例。
在下文中一共展示了Actions.Click方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TheXTest
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()");
}
示例2: MaxZoom
//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);
}
示例3: ShouldAllowSelectingMultipleItems
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);
}
示例4: ShouldAllowSelectingMultipleItems
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);
}
示例5: ShouldAllowClickingOnFormElements
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.");
}
示例6: ClickCategoryTree
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();
}
示例7: OpenBaseLayers
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);
}
示例8: KeyUpAndKeyDown
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);
}
示例9: CreateInd
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();
}
示例10: TestRowSelectionUsingControlKey
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);
}
示例11: TestRowSelectionUsingShiftKey
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);
}
示例12: ShouldAllowClickingOnFormElements
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.");
}
示例13: ToggleNavigationPan
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();
}
示例14: OpenGlobalMenu
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();
}
示例15: MouseClick
public void MouseClick(IWebElement element)
{
Console.WriteLine("Click the mouse on the element");
var builder = new Actions(Driver);
builder.Click(element).Perform();
}