草庐IT

selenium4

全部标签

python - Selenium webdriver.Firefox() 永远不会返回

~/selenium-test$whichgeckodriver/cygdrive/c/Windows/geckodriver~/selenium-test$geckodriver--version|head-n1geckodriver0.11.1~/selenium-test$python-iPython2.7.12(v2.7.12:d33e0cf91556,Jun272016,15:24:40)[MSCv.150064bit(AMD64)]onwin32Type"help","copyright","credits"or"license"formoreinformation.>>>

python - 如何使用 pythonw 运行 Selenium Webdriver?

我正在尝试通过Windows中的GUI应用程序在Selenium脚本中打开Firefox浏览器。它在使用python.exerunw.py运行时很好,但是当我使用pythonw.exerunw.py运行它时,浏览器无法启动。相反,它抛出这个异常:Traceback(mostrecentcalllast):File"bin\runw.py",line215,inprocess_instanceinstance.setup()File"bin\mixin.py",line181,insetupself.browser=self.get_firefox_browser()File"bin\m

c# - Selenium WebDriver - 找不到 Chrome 二进制文件

我正在尝试使用Chrome运行Selenium测试。我正在使用C#。varoptions=newOpenQA.Selenium.Chrome.ChromeOptions();options.BinaryLocation=@"C:\Users\Vilem\AppData\Local\Google\Chrome\Application\";using(IWebDriverdriver=newOpenQA.Selenium.Chrome.ChromeDriver(options)){...似乎找到了chromedriver.exe,但它可以找到Chrome二进制文件。我在自动搜索失败后显式设

c# - 从 Selenium webdriver 的当前窗口 GUID 获取窗口句柄 (IntPtr)

我正在trycatch整个浏览器屏幕(例如任何工具栏、面板等)的屏幕截图,而不仅仅是整个页面,所以我得到了这段代码:using(FirefoxDriverdriver=newFirefoxDriver()){driver.Navigate().GoToUrl(url);ScreenCapturesc=newScreenCapture();//HowcanIfindnaturalIntPtrhandleofwindowhere,usingGUID-likeidentifierreturningbydriver.currentWindowHandle?Imageimg=sc.Capture

selenium扫码登录操作edge

fromseleniumimportwebdriverfromselenium.webdriver.common.byimportByfromselenium.webdriver.common.action_chainsimportActionChainsfromselenium.webdriver.common.keysimportKeysimportjsonimporttimedriver=webdriver.Edge()deflogin_scan():#驱动器下载链接https://developer.microsoft.com/en-us/microsoft-edge/tools/we

c# - 如何从父元素获取文本并从子元素中排除文本(C# Selenium)

在Selenium中是否可以仅从父元素而不是其子元素获取文本?例子:假设我有以下代码:GoogleLinkThislinkwilltakeyoutoGoogle'shomepage....在C#(或任何语言)中,我将拥有:stringlinktext=driver.FindElement(By.CssSelector(".linksSection>a#google")).Text;Assert.AreEqual(linkText,"GoogleLink","GoogleLinkfailstexttest.");但是,链接文本将包含“GoogleLinkThislinkwilltakey

selenium无法获取到标签的文本内容(text)的解决方法

在我们使用selenium进行抓取网页的时候,可能有的时候会抓取不到内容。例如:driver.find_element_by_xxx().text()为空的解决办法  在用driver.find_element_by_xxx().text()获取文本的时候,得到的文本为空,那么当前定位的元素可能被隐藏了。我们先查看当前的元素的原始代码 我们发现是有内容的,但是取出时是空。怎么判断是否被隐藏呢,可以通过.is_displayed()方法来判断。 我们可以看到返回时False,确实被隐藏了。这时我们就需要考虑怎么才能获取到我们需要的数据了。在某些情况下,我们需要获取隐藏元素的文本。这些内容可以使用

c# - Selenium RemoteWebDriver c# - System.InvalidOperationException

我有一个使用Selenium.WebDriverv3.4.0的示例UI测试项目。当我针对本地驱动程序运行测试时,一切正常,但我想使用SeleniumGrid2让一切正常工作。当我尝试实例化一个新的RemoteWebDriver时,我得到了一个没有细节的异常。Driver=newRemoteWebDriver(newUri(GridUrl),Capabilities);注意:GridUrl为“http://localhost:4444/wd/hub”使用StackTrace抛出System.InvalidOperationException,如下所示:atOpenQA.Selenium.

c# - Selenium WebDriver.ChromeDriver Nuget 包已安装,但不适用于 MSTest

我添加了WebDriver.ChromeDrivernuget包到我的解决方案,其中包含ChromeDriver.exe文件,SeleniumWebDriver需要使用Chrome运行自动测试。查看包内容,它只包含以下文件:tools\chromedriver.exe应该要做的是将此文件夹添加到PATH环境变量中,以便可以通过以下代码访问chromedriver.exe(这是在UnitTest项目中使用MSTest):[TestMethod]publicvoidLaunchWebsite_Chrome(){//createChromeDriver-thisshouldworkifchr

c# - 使用 Selenium2,如何检查页面上是否存在某些文本?

我正在使用C#SeleniumWebDriver,我想确认页面上是否存在某些文本。我该怎么做?所有选择器似乎都使用ID、类等。我不关心文本在页面上的位置,我只想确保它存在于页面上某处。有什么想法吗?PS:我可以使用JQuery和Javascript来做到这一点,但显然并非所有浏览器驱动程序都支持它:protectedboolTextIsOnThePage(stringtextToFind){varjavascriptExecutor=((IJavaScriptExecutor)_driver);booltextFound=Convert.ToBoolean(javascriptExec