Tag: seleniumwebdriver

如何在WebDriver中处理iframe

<div> <iframe id="cq-cf-frame "> <iframe id="gen367"> <body spellcheck="false" id="CQrte" style="height: 255px; font-size: 12px; font-family:tahoma,arial,helvetica,sans-serif; background-image: url(&quot;/libs/cq/ui/widgets/themes/default/ext/form/text-bg.gif&quot;); background-repeat: repeat-x; background-attachment: fixed;"> <p>4t43t4<br></p> </body > </iframe> </iframe> </div> 在这种情况下iframe下有一个iframe 。 我必须select外部iframe去内部iframe并写入内部iframe中的主体。 接下来,我必须从内部iframe走出到外部iframe ,然后单击OKbutton(位于外部iframe )。 以下是我的代码 /*Line 1 */ driver.switchTo().frame("cq-cf-frame"); /* 2 */ driver.findElement(By.css("#extdd-9 > div.tblRow > input.edititem").click(); /* 3 */ driver.switchT().Frame("cq-gen379"); /* 4 */ driver.findElement(By.id("CQrte").sendKeys("Tnx"); /* 5 […]

使用Java使用Selenium WebDriver加载Chromeconfiguration文件

我有一些麻烦,让selenium加载铬configuration文件。 String pathToChrome = "driver/chromedriver.exe"; System.setProperty("webdriver.chrome.driver", pathToChrome); DesiredCapabilities capabilities = DesiredCapabilities.chrome(); String chromeProfile = "C:\\Users\\Tiuz\\AppData\\Local\\Google\\Chrome\\User Data\\Default"; ArrayList<String> switches = new ArrayList<String>(); switches.add("–user-data-dir=" + chromeProfile); capabilities.setCapability("chrome.switches", switches); WebDriver driver = new ChromeDriver(capabilities); driver.get("http://www.google.com"); 它开始很好,工作完美,但我想获得加载的默认configuration文件,因为我想testing它启用了一些扩展和一些首选项testing。 有没有人有一个想法,为什么这个代码不工作? 我用Selenium 2.29.1和2.28.0在windows 7 x64上使用chromedriver 26.0.1383.0进行了testing。

Selenium可以与现有的浏览器会话进行交互吗?

有人知道Selenium(WebDriver最好)是否能够在启动Selenium客户端之前就已经运行的浏览器进行通信和操作? 我的意思是,如果Selenium能够在不使用Selenium服务器的情况下与浏览器通信(例如可以手动启动Internet Explorer)。

什么时候使用Selenium Webdriver的显式等待与隐式等待?

我在用: driver.manage().timeouts().implicitlyWait(180, TimeUnit.SECONDS); 但是对于下面的元素,它仍然会失败 driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys("Create_title_01"); 我已经添加了等待代码: for (int second = 0;; second++) { if (second >= 120) fail("timeout"); try { if (isElementPresent(By.id("name"))) break; } catch (Exception e) {} Thread.sleep(1000); } 不应该隐含的等待,等待一个元素被发现? 如果我使用显式等待,而不是我已经添加了Thread.sleep()的代码,它也会更好吗?

selenium2.53不适用于Firefox 47

使用WebDriver使用Firefox时出现错误。 org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox版本:47.0 selenium:2.53.0 Windows 10 64位 有没有人得到类似的问题或任何想法这是什么解决scheme? Chrome浏览器工作正常,但Firefox浏览器没有任何URL正在加载。