Tag: selenium webdriver

如何找到页面上是否存在文本

如果文本存在,则单击xyz否则单击abc 。 我正在使用下面的if语句: if(driver.findElement(By.xpath(“/html/body/div[2]/div/div/div/div/div/div/table/tbody/tr[6]/td[2]”)).isDisplayed()) { driver.findElement(By.linkText(“logout”)).getAttribute(“href”); } else { driver.findElement(By.xpath(“/html/body/div/div/div/a[2]”)).click(); } 脚本失败,并显示以下错误消息: Unable to locate element: {“method”:”xpath”,”selector”:”/html/body/div[2]/div/div/div/div/div/div/table/tbody/tr[6]/td[2]”}

针对多个浏览器运行selenium webdriver测试用例

我是selenium测试的新手。 我想在多个浏览器上针对Internet Explorer,Firefox,opera和chrome运行selenium test cases 。 我必须遵循什么方法。 请问有人请建议我哪个是最好的流程。 selenium web驱动程序是否支持多个浏览器? 我们写了登录脚本。 它单独运行Firefox,Chrome和Internet Explorer。 但我想顺序为那些多个浏览器运行它。

Selenium Webdriver远程设置

我在我的本地机器上运行selenium-server-standalone.jar,我想在远程机器上编译运行的测试,但我不知道如何让测试连接到将运行浏览器的机器。 任何帮助赞赏。 更新:在我的本地机器上(我将运行浏览器的那台机器)我跑了 java -jar selenium-server-standalone-2.25.0.jar -mode hub 在我的远程机器上(我将运行测试)我跑了 java -jar selenium-server-standalone-2.25.0.jar -role webDriver -hub http://**My ip*:4444 我的代码包含以下内容: @Before public void setUp() throws Exception { DesiredCapabilities capability = DesiredCapabilities.firefox(); driver = new RemoteWebDriver(new URL(“http://**My ip**:4444/wd/hub”), capability); baseUrl = “http://phy05:8080”; driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); driver.manage().window().setSize(new Dimension(1920, 1080)); 我正在使用Linux,我的测试是用Java编写的

我在运行JAVA webdriver代码时遇到了错误。 这与ChromeDriver有关

当我尝试运行以下代码时,我得到的错误与ChromeDriver 。 我是新手,但我可以看到代码到第11行但是它失败了 。 线程“main”中的exceptionjava.lang.IllegalStateException:驱动程序可执行文件不存在:位于org的com.google.common.base.Preconditions.checkState(Preconditions.java:199)中的C:\ Matts Learning \ ChromeDriver \ ChromeDriver。 openga.selenium.remote.service.DriverService.checkExecutable(DriverService.java:121)位于org.openqa.selenium.chrome.ChromeDriverService的org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:116)。在org.openqa.selenium.remote.service.DriverService $ Builder.build(DriverService.java)的org.openqa.selenium.chrome.ChromeDriverService $ Builder.findDefaultExecutable(ChromeDriverService.java:137)访问$ 000(ChromeDriverService.java:32) :296)org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)at org.openqa.selenium.chrome.ChromeDriver。(ChromeDriver.java:116)at TestTiscaliLogin.main(TestTiscaliLogin.java:13 )

java.lang.OutOfMemoryError:使用apache POI读取excel文件时超出了“GC开销限制”

我们正在使用Apachi POI从excel文件中读取数据,它为我们的Selenium自动化测试用户提供了800行输入数据。 我们已经使用jenkins配置并执行了批处理作业,它工作了一年多。 但现在它显示错误“线程中的exception”主“java.lang.OutOfMemoryError:超出GC开销限制”。 当我们将JVM内存大小增加到1024 MB时,它工作正常。 excel文件大小只有68KB。 但它显示GC错误。 能否帮助我们解决问题的原因。 我们如何能够为这个问题提供永久的解决方案。 Excel工作表中的总行数为800 excel表文件大小为68KB 获取错误消息: Exception in thread “main” java.lang.OutOfMemoryError: GC overhead limit exceeded”. 请在此处找到附带的屏幕截图, 输入图像说明

使用selenium java在firefox gecko驱动程序中自动下载pdf

任何人都可以帮助创建配置文件并使用firefox( gecko 驱动程序 )设置选项,以自动下载selenium webdriver – java中的文件。 我已经搜索了很多谷歌搜索的选项,没有什么工作。 所以在堆栈溢出时发布我的查询。 如果可能,请帮助一些代码段。 这适用于selenium 3和firefox 52。 提前致谢。

自动化测试错误:org.openqa.selenium.WebDriverException:disconnected:无法连接到渲染器

我是自动化测试的新手,我面临以下错误。 我无法继续下去。 有人可以帮我解决这个问题:{错误} Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 47649 Only local connections are allowed. Feb 06, 2018 4:48:10 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS Exception in thread “main” org.openqa.selenium.WebDriverException: disconnected: unable to connect to renderer (Session info: chrome=64.0.3282.140) (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7601 SP1 x86) (WARNING: The server did not provide any […]

无法在testng.xml文件中为不同的浏览器运行回归组

我已经配置了testng.xml文件以在不同的浏览器中运行Regression组.Below是相同的testng.xml代码。 当我将鼠标hover在标签上时,它会显示一条错误消息“ 元素类型的内容”测试“必须匹配”(方法选择器?,参数*,组?,包?,类?) “。在测试中class level我已经为回归测试正确定义了所有参数。但是我仍然看到testng.xml文件中的错误。你们中的任何一个人都可以看看并帮助我! 请找到我用于自动化的测试用例 @Test(groups={“Regression”},dataProvider = “hashmapdataprovider”,dataProviderClass =Dataprovider.Dataprovider_Hashmap.class,priority=1 ) public void validLogin(Map hm) throws IOException { pageobjects.Signin(); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); OriginalExcelRW Excel = new OriginalExcelRW(“F:\\anand_acer\\selenium\\rediffbooks.xlsx”); XSSFSheet s1 = Excel.Setsheet(“Sheet1”); SoftAssert s_assert = new SoftAssert(); if (hm.get(“Executionflow”).contains(“anand”)) { pageobjects.Username1(hm.get(Excel.Readvalue(s1, 0, 2))); pageobjects.pass1(hm.get(Excel.Readvalue(s1, 0, 3))); //s_assert.assertEquals(hm.get(Excel.Readvalue(s1, 0, 2)), hm.get(Excel.Readvalue(s1, 0, 3)), “both the usssser Ideee and […]

网页>>框架>>弹出窗口处理

我有这个网页,我试图自动化。 这是应用程序的步骤和function。 使用Selenium启动应用程序 在单击某个按钮时,将在主网页上弹出一个框架 我能够通过selenium web驱动程序执行框架操作 但是在同一帧中有一个日历图标。 一旦您点击日历图标,弹出一个带有日历和确定按钮的弹出窗口。 我可以在弹出窗口中选择日期,只要单击“确定”按钮,弹出窗口就会自动关闭。 现在我想再次切换到FRame以执行进一步的操作。 但我不能这样做。 我的脚本崩溃,错误“未找到窗口。浏览器窗口可能已关闭。” 下面是我的代码的一部分 Driver.findElement(By.xpath(“//input[@id=’VDC_VM_ScheduledTask.RequestedDateTime.ControlImage’]”)).click(); // clicking on calendar icon Set afterPopup = Driver.getWindowHandles(); System.out.println(afterPopup); afterPopup.removeAll(beforePopup); System.out.println(afterPopup.size()); if(afterPopup.size() == 1) { Driver.switchTo().window((String)afterPopup.toArray()[0]); Driver.findElement(By.id(“submitButton”)).click(); // Switching windows and clicking Ok in calendar pop up window which closes it automatically } Driver.switchTo().frame(0); // this step fails

如何使用Selenium WebDriver选择新的IFrame?

我想在Body中选择一个Iframe和Enter值。 我正在尝试使用以下代码。 HTML代码: Selenium代码: driver.switchTo().frame(driver.findElement(By.xpath(“//iframe[contains(@id,’content_ifr’)]”))); driver.findElement(By.xpath(“//*[@id=’tiny’]/div[1]”)).sendKeys(“Happy New IFrame”); 但我无法输入值。 任何人都可以帮我吗?