Tag: selenium chromedriver

从Selenium触发时,Google Chrome无法导航到指定的url

我有一个围绕Selenium-WebDriver开发的自动化框架,它启动Chrome并导航到指定的URL并执行指定的自动化。 当我委托框架执行一项长任务并让它在一夜之间运行时(运行不成功)。 第二天,当我尝试重新运行一组新的测试时,Selenium能够启动Chrome,但浏览器无法导航到指定的URL。 以下是详细的堆栈跟踪。 Starting ChromeDriver (v2.7.236900) on port 60678 Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html (Session info: chrome=41.0.2272.118) (Driver info: chromedriver=2.7.236900,platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 10.12 seconds Build […]

ChromeDriver:自定义Chrome可执行文件路径

我正在使用便携版Google Chrome。 由于WebDriver需要默认安​​装路径,因此它找不到显然位于其他位置的便携式路径: Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 11.13 seconds Build info: version: ‘2.35.0’, revision: ‘8df0c6b’, time: ‘2013-08-12 15:43:19’ System info: os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: […]

将选项传递给chrome驱动程序selenium

我试图禁用输出到控制台的chrome。 如果我通过–start-maximized选项,它可以正常工作。 我可能有错误的命令? DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability(“chrome.switches”, Arrays.asList(“–silent”)); chrome = new ChromeDriver(_chromeservice,capabilities); 我也试过了 ChromeOptions options = new ChromeOptions(); options.addArguments(“silent”); chrome = new ChromeDriver(options); 产量 已启动ChromeDriver port = 26703 version = 23.0.1240.0 log = / Brett / workspace / TestNG / chromedriver.log [1214/161331:ERROR:ipc_sync_channel.cc(378)]取消待处理的发送[1214/161331:错误:ipc_sync_channel.cc( 378)]取消待处理的发送[1214/161331:错误:ipc_sync_channel.cc(378)]取消待处理的sendBlockquote

SessionNotFoundException:会话ID为空。 调用quit()后使用WebDriver? (selenium)

我正在尝试使用Cucumber / Java编写一些selenium自动UI测试。 如果我的function文件中只有一个测试,一切正常。 但是如果我添加第二个测试,我会在driver.get()上收到此错误: org.openqa.selenium.remote.SessionNotFoundException: Session ID is null. Using WebDriver after calling quit()? Build info: version: ‘2.51.0’, revision: ‘1af067dbcaedd7d2ab9af5151fc471d363d97193’, time: ‘2016-02-05 11:20:57’ 基本上,我在一个包中初始化InitializeWebdriver类上的webdriver变量,然后在其他(步骤定义)类中引用它。 我确实将下面列出的步骤定义作为InitializeWebdriver类的一部分,并且它工作正常(直到移到另一个类中的不同步骤。所以我将该步骤移动到CommonSteps.java文件以查看它是否然后它会失败,它就会失败。所以现在我只是卡住了。我想在if (driver.equals(null))中做一个if (driver.equals(null))并且如果已经初始化那么做一个不同的动作,但我不知道我知道其他行动会是什么。 这是我的代码: tests.feature Feature: Two tests Background: Given I navigate to “http://www.google.com” Scenario: Test one When something happens Scenario: Test two When something else happens InitializeWebDriver.java public class […]

如何处理没有任何元素的浏览器通知弹出窗口?

如何按照图像按OK按钮。 我可以切换到这个窗口。 但它没有加载,直到我点击确定,所以没有任何元素。 警报手柄也没有帮助。 Autoit也无法检测到此弹出消息。 禁用通知也无法帮助。 有任何想法吗? 添加了两个screeshots。 Firefox快照: Chrome快照: p.companieGenreal.sActivities().click(); driver.switchTo().defaultContent(); String parent = driver.getWindowHandle(); p.companieGenreal.sAddNew().click(); p.companieGenreal.sAddJobOrder().click(); p.companieGenreal.sContract().click(); swithToChildWindow(parent); driver.switchTo().alert().accept();

ChromeDriver和WebDriver for Selenium通过TestNG导致4个错误

我正在做网站所说的,但它导致了4个错误……

禁用Chrome通知(Selenium)

我只是想在Selenium Java应用程序打开的Chrome中禁用Chrome通知。 (使用java代码) 这样的通知: 问题是在浏览器窗口关闭后手动设置的设置会丢失。

运行selenium remotedriver时出现带有NativeConstructorAccessorImpl.newInstance0的SessionNotCreatedException错误

我运行以下但得到错误 public class base { public static WebDriver driver; public static void main(String[] args) throws MalformedURLException, InterruptedException { System.setProperty(“webdriver.chrome.driver”, “C:\\code\\lib\\browser drivers\\chromedriver.exe”); String URL = “http://www.google.com”; String Node = “http://localhost:4444/wd/hub”; DesiredCapabilities cap = DesiredCapabilities.chrome(); cap = DesiredCapabilities.chrome(); cap.setPlatform(org.openqa.selenium.Platform.WINDOWS); driver = new RemoteWebDriver(new URL(Node), cap); driver.navigate().to(URL); Thread.sleep(5000); driver.quit(); } } 显示的错误如下: Exception in thread “main” org.openqa.selenium.SessionNotCreatedException: Unable […]

使用无头浏览器进行调试

我有一个WebDriver测试套件,当我在普通和无头浏览器中执行它时,它运行不同。 当我在无头模式下执行它时,找不到一个元素,但是当我在正常模式下使用相同的代码,相同的驱动程序时,会发现该元素。 我用这个标志来设置无头模式: chromeOptions.addArguments(“–headless”); 正在使用ChromeDriver 2.31和WebDriver 3.5.2 。 我怎么调试这个?

如何在Selenium中获取WebElement的HTML代码

我是测试的新手,所以如果我的问题听起来有些重要,我会提前道歉。 我正在使用Selenium和Java来编写测试。 我知道webElement.getAttribute(“innerHTML”); 给我带来innerHTML,例如下面的元素: close 它返回: close 但我需要一些东西给我带来WebElement“a”的内在属性,如下所示: href=”#” class=”ui-dialog-titlebar-close ui-corner-all” role=”button” style=”position: absolute; border-radius: 0px 0px 4px 4px;”