Tag: webdriver

我可以同时在不同的端口上运行selenium服务器吗?

我看到这篇文章关于如何在2个不同的端口上运行selenium web驱动器服务器。 我试过这样做: java -Dwebdriver.chrome.driver=./chromedrive -jar selenium-server-standalone-2.44.0.jar -port 4445 java -Dwebdriver.chrome.driver=./chromedrive -jar selenium-server-standalone-2.44.0.jar -port 4444 并运行在端口4445上调用服务器的代码 但我得到这个例外: rond-macpro:selenium eladb$ java -Dwebdriver.chrome.driver=./chromedrive -jar selenium-server-standalone-2.44.0.jar -port 4445 17:26:14.740 INFO – Launching a standalone server 17:26:14.780 INFO – Java: Oracle Corporation 24.76-b04 17:26:14.781 INFO – OS: Mac OS X 10.9.5 x86_64 17:26:14.793 INFO – v2.44.0, with Core v2.44.0. […]

如何通过webdriver测试输入字段function的屏蔽

您好我想测试密码字段是否屏蔽了密码字段中输入的字符串。 我怎么能通过webdriver测试它。 我试过下面的事情: package unitTest.JUnitTestCases; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class PasswordTest { @Test public void test() { WebDriver driver=new FirefoxDriver(); driver.manage().window().maximize(); driver.get(“http://docs.sencha.com/extjs/4.2.1/extjs-build/examples/form/adv-vtypes.html”); WebElement username=driver.findElement(By.id(“textfield-1014-inputEl”)); username.sendKeys(“admin”); System.out.println(username.getText()); WebElement password=driver.findElement(By.id(“textfield-1015-inputEl”)); password.sendKeys(“admin”); System.out.println(password.getAttribute(“textContent”)); //WebElement login=driver.findElement(By.id(“login”)); } } 在这里,我输入密码字段中的某个值,并尝试获取在该字段中输入的文本,以便我将检查它是否被屏蔽。 TIA!

如何在使用java单击链接时打开新窗口

if(driver.findElement(By.xpath(“xxx”)).isDisplayed() != True){ // if clicked in the above condition is True then it has to be opened in a new window driver.findElement(By.xpath(“xxx”)).click(); } else { System.out.println(“element not present — so it entered the else loop”); }

无法阅读VR Path Registry – Selenium Webdriver

我正在尝试使用Selenium和java执行测试用例,但页面没有完全加载,我在eclipse控制台中收到此消息: 无法读取VR Path Registry 这条消息是什么意思? 这是代码 FirefoxDriver driver = new FirefoxDriver(); try { driver.get(url); WebDriverWait wait = new WebDriverWait(driver, 10); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(idName))); … 控制台: 1513781293556 Marionette INFO Enabled via –marionette Unable to read VR Path Registry from C:\Users\jo\AppData\Local\openvr\openvrpaths.vrpath [Parent 12932, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346 Unable to read VR Path […]

使用webdriver找不到元素

有一个网络元素: A B 因为它有onchange ,我无法选择该选项。 我的代码是这样的: new Select(driver.findElement(By.id(“sel”))).selectByValue(“1”); 但它无法奏效。 是否有可能使它工作?

需要在没有Thread.sleep的情况下编写selenium代码

我写了以下代码登录网站“qtpselenium.com” 。 如果我在其间给出Thread.sleep以使代码执行暂停一段时间,下面的代码工作正常。 如果我评论Thread.sleep,代码不能按预期工作。 我试图使用selenium的隐式和显式等待使驱动程序等待元素可见,但代码只能在我使用Thread.sleep时按预期工作。 有没有办法,我可以使用下面的代码,而不使用Thraed.Sleep语句。 在selenium代码中使用Thread.sleep语句是不好的做法? import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.FluentWait; public class QTPSelenium { public static WebDriver driver = null; public static void main(String[] args) throws InterruptedException { System.setProperty(“webdriver.gecko.driver”,”C:\\Eclipse\\Drivers\\geckodriver.exe”); driver = new FirefoxDriver(); driver.get(“http://qtpselenium.com/”); driver.findElement(By.xpath(“.//*[@class=’btn btn-default member_login’]”)).click(); Thread.sleep(10000); driver.findElement(By.xpath(“(//button[@type=’submit’])[3]”)).click(); Thread.sleep(10000); driver.findElement(By.id(“email”)).sendKeys(“Some Email ID”); driver.findElement(By.id(“login-password”)).sendKeys(“Some Password”); driver.findElement(By.xpath(“html/body/main/div[2]/div/div/div[1]/div/div/div/form/button”)).click(); […]

测试通过但行动没有发生selenium webdriver + testng

我是selenium webdriver的新手,我在IE 8上使用2.31版本,testng 6.8和防火测试。我在这个方案中编写我的测试:我有测试类,我有使用testng @Test注释的方法。 它看起来像这样: @Test(description=”click Save Button “, dependsOnMethods = { “edit form” }) public void clickSaveButton(ITestContext context) { page.clickSaveButton(driver); } 然后,正如你所看到的,我有一个页面类,我存储元素id,xpath等。它像这样lokks: public void clickSaveButton(WebDriver driver){ Configuration.clickfoundElement(By.id(conf.get(“saveButton”)), driver); } conf是表示属性文件的对象。 最后我有Configuration类,我在这里做了一些思考: public static void clickfoundElement(By by, WebDriver driver){ int attempts = 0; while(attempts < 10) { try { driver.findElement(by).click(); break; } catch(NoSuchElementException e) […]

Java – Selenium WebDriver – 如何检查文件下载对话框是否可见? (不下载只有可见性)

是否可以使用Selenium WebDriver或任何其他Java库检查IE中的文件下载对话框是否可见? 我不想下载该文件。 我无法validation对话框的可见性。 此外,我无法关闭对话框。 有帮助吗?

如何使用不同的包管理Selenium项目代码(如页面对象模型/关键字驱动程序框架)

作为自动化的第一次用户,我正在寻找与自动化项目组织和其他相关内容相关的帮助。 任何人都可以和我一起分享样本项目。 我可以编写脚本,但我无法管理java中的代码。 建议我任何网站的最佳方式。

如何找到下拉列表的选定选项?

我们如何在Selenium Webdriver中找到Dropdown的选定选项? 我试过了 – WebElement element = driver.findElement(By.xpath(locator1)); Select select = new Select(element); List SO = select.getAllSelectedOptions(); String S = SO.toString(); System.out.println(S); 返回WebElements,如 – [[[[[FirefoxDriver: firefox on XP (c388e8a8-09d5-41b9-b086-0278c639d8b1)] -> xpath: .//*[@id=’city’]]] -> tag name: option]] 我想找到被选中的选项?