Tag: selenium webdriver

Selenium – 带透明代理的MoveToElement()

我有元素 public ArticlePage() { PageFactory.InitElements(Browser.driver, this) } [FindsBy(How = How.Id, Using = “someId”)] private IWebElement btnTitleView { get; set; } 和行动 Actions action = new Actions(Browser.driver); action.MoveToElement(btnTitleView).Perform(); 但是当我尝试运行它时,我会收到错误 ‘System.Reflection.TargetException’对象与目标类型不匹配。 我试图通过Browser.driver.FindElement(By.Id(“someId”))找到这个元素,然后它正常工作。 因此,它存在并显示。 是否可以使用透明代理来执行Actions ? 有没有其他方法可以对透明代理执行MoveToElement()操作?

OpenQA.Selenium.WebDriverException:未知错误:Chrome无法启动:在Linux上通过Selenium执行测试时exception退出

我创建了一个使用Selenium的应用程序,使用.NetCore在Linux上使用它,实际上这是我的代码实现: public class Program { public static async Task Main(string[] args) { //Settings for chrome var chromeOpts = new ChromeOptions(); chromeOpts.AddArgument(“headless”); chromeOpts.AddArgument(“no-sandbox”); //Get assembly path where chrome driver is located string codeBase = Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); path = Path.GetDirectoryName(path); var driver = new ChromeDriver(path, chromeOpts, TimeSpan.FromSeconds(180)); } } […]

Selenium – C# – Webdriver – 无法找到元素

在C#中使用selen我正在尝试打开浏览器,导航到Google并找到文本搜索字段。 我试试下面的 IWebDriver driver = new InternetExplorerDriver(@”C:\”); driver.Navigate().GoToUrl(“www.google.com”); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); IWebElement password = driver.FindElement(By.Id(“gbqfq”)); 但得到以下错误 – 无法找到id == gbqfq的元素

WebDriver.dll中发生了未处理的“System.InvalidOperationException”类型exception

我正在学习seleniumC#教程,我正处于第一阶段。 因此,当我运行我的控制台应用程序时,我收到以下错误。 WebDriver.dll中发生了未处理的“System.InvalidOperationException”类型exception 附加信息:未知错误:无法识别Blink修订版:3b3c00f2d95c45cca18ab944acced413fb759311 它在控制台中说 仅允许本地连接 我的代码 class Program { static void Main(string[] args) { IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl(“http://www.google.lk”); } }

如何在不关闭它的情况下在同一浏览器实例中运行多个测试方法(C#,SeleniumWebDriverz NUnit)?

我是c#和Selenium的初学者。 我想知道是否可以在相同的浏览器实例中运行多个[TestMethod] -s而不关闭它? 例如,在“Can_Change_Name_And_Title”完成之后,我想继续“Can_Change_Profile_Picture”。 [TestMethod] public void Can_Change_Name_And_Title() { SidebarNavigation.MyProfile.GoTo(); ProfilePages.SetNewName(“John Doe”).SetNewTitle(“New Title Test”).ChangeNameTitle(); } [TestMethod] public void Can_Change_Profile_Picture() { SidebarNavigation.MyProfile.GoTo(); ProfilePages.SetNewProfilePicture(Driver.BaseFilePath + “Profile.png”).ChangeProfilePicture(); }

PHantom JS 50%的时间都失败了

我搜索一个文本框,然后尝试用字符串填充它。 这是代码: var fname = _driver.FindElement(By.Name(“iFirstName”), 50); if(fname!=null) { do { System.Threading.Thread.Sleep(500); } while (!fname.Displayed); fname.SendKeys(myName); } FindElement函数是这样的: public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds) { if (timeoutInSeconds > 0) { var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds)); return wait.Until(drv => drv.FindElement(by)); } return driver.FindElement(by); } 有些时候文本框中填充了字符串,有时我收到此错误: System.InvalidOperationException: {“errorMessage”:”‘undefined’ is not an object […]

Selenium – Modal对话框目前 – 如何接受信息?

我有以下问题。 在页面上提交一些日期后,我有一个modal dialog,如图所示: 我想点击“ENTER”来完成该模态,但它不起作用。 我有以下代码: driver.FindElement(By.CssSelector(“input.submit”)).Click(); Actions action = new Actions(driver); action.SendKeys(OpenQA.Selenium.Keys.Enter); 点击继续手动测试后返回下一页。 我必须通过这个模式继续测试。 任何想法如何解决这个问题?

以编程方式启动用于Selenium测试的.NET Core Web应用程序

我目前正在尝试在Core Web应用程序上设置一些UI测试,但是我无法启动Web应用程序。 从Web应用程序目录直接使用命令行“dotnet run”工作。 当我在执行测试之前尝试使用Process来运行它时,问题就出现了。 var process = new Process { StartInfo = { FileName = “dotnet”, Arguments = “run”, WorkingDirectory = applicationPath } }; process.Start(); 有没有人在遇到类似的问题之前和/或设法解决它? 我可能会误用Process 。

使用Selenium WebDriver查找任何给定元素的下一个兄弟

我正在尝试创建一个给定WebElement查找并返回下一个元素的方法。 我已经找到了很多关于使用带有“follow”或“follow-sibling”的XPath应该工作的例子,但是我无法让它工作。 为了这个问题的目的,我将展示html,但是元素类型与我需要的东西无关,因为我想要一个给定任何类型的任何元素的通用方法(a / ul / div / whatever)它将返回下一个兄弟姐妹,不论其类型。 “My Label” … … 我的错误调试代码: IWebElement element = driver.FindElement(By.Id(“blah”)); IWebElement nextElement = element.FindElement(By.XPath(“//following-sibling::ul[@class=’some-class’]”)); 我怀疑我的xpath语法是错误的…我坦率地说是无能为力。 “//”是指相对于元素还是DOM本身? 有没有办法在不知道下一个元素的标签是什么的情况下这样做? 无论它是什么类型,我都想获得下一个元素。 我只想弄清楚最简单,最通用的方法。 我想要的是: public IWebElement NextSibling(IWebElement element) { IWebElement nextSibling = element.FindElement(By.?(“magical string to find next sibling”)); return nextSibling; } …这正是你在javascript中已经可以用element.nextSibling()做的事情

是否有WebDriver Navigated事件?

.NET WebBrowser具有Navigated事件。 Selenium WebDriver是否有类似的事件? 我搜索过但没找到任何东西。