只是我今天有一个简单的问题: 我用这个代码创build了一个新的selenium项目: FirefoxDriver driver = new FirefoxDriver(); //ChromeDriver driver = new ChromeDriver(); //InternetExplorerDriver driver = new InternetExplorerDriver(); 随着Chrome和IE开箱即用,但与Firefox抛出: geckodriver.exe文件不存在于当前目录或PATH环境variables的目录中。 驱动程序可以在https://github.com/mozilla/geckodriver/releases下载。 为什么只有Firefox才能下载/configuration这个驱动程序?
试图find一种方法来禁用Firefox提出警告,每次连接使用“不受信任”的证书,Selenium。 我相信那种最好的解决scheme是设置一个浏览器偏好。 非常感谢! 任何build议将不胜感激!
我必须处理打印对话框(在浏览器中单击ctrl-p时出现的对话框)。 我试着用: Alert printDialog = driver.switchTo().alert(); printDialog.dismiss(); 但它没有工作。 我也无法赶上它的窗户把手,因为这不是一个窗口… 是否有可能处理这些对象,以及如何?
我正在阅读SeleniumHQ文档,并且遇到以下声明。 警告:不要混合隐式和显式的等待,这样做会导致不可预知的等待时间,例如设置10秒的隐式等待和15秒的显式等待,可能导致20秒后发生超时。 出于某种原因,我无法理解这一点。 总超时20秒是我的主要困惑点。 任何人都可以解释,如果我错过了什么? 编辑 我的问题不是混合这些等待的实施/后果。 这完全是关于文档的超时声明和计算。 第二编辑 看起来像下面的testing文档是正确的。 我仍然需要解释 。 只是隐含的等待 using System; using System.Diagnostics; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; namespace Test { [TestFixture] public class Test { private IWebDriver _webDriver; [Test] public void ExplicitVsImplicitWaitTest() { _webDriver = new ChromeDriver(); _webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); _webDriver.Navigate().GoToUrl("https://www.google.com/"); _webDriver.Manage().Window.Maximize(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { //new […]
我有一个Selenium WebDriver的问题。 我尝试点击窗口页面外的链接(您需要向上滚动以查看)。 我目前的代码是相当标准的: menuItem = driver.findElement(By.id("MTP")); menuItem.click(); // I also tried menuItem.sendKeys(Keys.RETURN); 我知道我可以向上滚动,在这种情况下,它会起作用。 但是如果你有一个长长的项目列表,你不一定知道你需要向下滚动多less。 有什么办法可以点击不在页面可见部分的链接(但是如果你滚动的话就可以看到)? 作为一个方面说明,我使用Firefox,但我打算使用IE7 / 8/9和Chrome。 任何帮助将不胜感激。 编辑:恐怕我不能给源代码,因为我工作的公司不允许它,但我可以给我点击链接的代码: <div class="submenu"> <div id="MTP">Link title</div> </div> 当链接可见时,完全相同的代码工作,只有当链接不可用时才起作用。 编辑2:其实,奇怪的是,它不会引发任何exception,只是去下一个指令。 所以基本上,会发生什么是: menuItem = driver.findElement(By.id("MTP")); // no exception menuItem.click(); // no exception //… some code ensuring we got to the next page: timeout reached driver.findElement(By.id("smLH")).click(); // NoSuchElementException, […]
我一直在使用selenium (通过python绑定和通过protractor )相当长的时间,每次我需要执行一个JavaScript代码,我已经使用execute_script()方法。 例如, 滚动页面 (python): driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") 或者,对于另一个元素 (量angular器) 内的无限滚动 : var div = element(by.css('div.table-scroll')); var lastRow = element(by.css('table#myid tr:last-of-type')); browser.executeScript("return arguments[0].offsetTop;", lastRow.getWebElement()).then(function (offset) { browser.executeScript('arguments[0].scrollTop = arguments[1];', div.getWebElement(), offset).then(function() { // assertions }); }); 或者,获取所有元素属性 (python)的字典 : driver.execute_script('var items = {}; for (index = 0; index < arguments[0].attributes.length; ++index) { items[arguments[0].attributes[index].name] = arguments[0].attributes[index].value […]
任何人都可以告诉我如何识别和切换到只有一个标题的iframe? <iframe frameborder="0" style="border: 0px none; width: 100%; height: 356px; min-width: 0px; min-height: 0px; overflow: auto;" dojoattachpoint="frame" title="Fill Quote" src="https://tssstrpms501.corp.trelleborg.com:12001/teamworks/process.lsw?zWorkflowState=1&zTaskId=4581&zResetContext=true&coachDebugTrace=none"> 我已经尝试了下面的代码,但它不工作 driver.switchTo().frame(driver.findElement(By.tagName("iframe")));
所以我正在与C#winformselenium火狐webdrivers和我有下面的代码来获得popup窗口的句柄,当你点击“webtraffic_popup_start_button”,它应该得到popup的句柄,但popup的句柄是相同的作为目前的一个。 string current = driver.CurrentWindowHandle; driver.FindElement(By.XPath("//*[@id='webtraffic_popup_start_button']")).Click(); Thread.Sleep(Sleep_Seconds); popup = driver.CurrentWindowHandle; Thread.Sleep(3000); driver.SwitchTo().Window(current); Thread.Sleep(1000); 任何帮助,将非常感谢你 这是popup的样子。
我设置了一个python代码来运行Selenium chromedriver.exe 。 在运行结束时,我有browser.close()来closures实例。 ( browser = webdriver.Chrome() )我相信它应该从内存释放chromedriver.exe (我在Windows 7上)。 但是,每次运行后有一个chromedriver.exe实例保留在内存中。 我希望有一种方法,我可以用python写一些东西来杀死chromedriver.exe进程。 很明显, browser.close()不做这个工作。 谢谢。
我使用Selenium WebDriver和Java,我需要自动化file uploadfunction。 我尝试了很多,但点击浏览button的时候,一个新的窗口打开脚本停止执行进一步,而是卡住了。 我尝试在Firefox和IE驱动程序,但无济于事。 我也尝试通过调用一个自动执行文件,但随着新窗口打开点击浏览button,特定的声明 Runtime.getRuntime().exec("C:\\Selenium\\ImageUpload_FF.exe") 不能执行。 请帮助