Tag: selenium webdriver

在范围报告中添加测试用例失败原因

我在用 selenium webdriver java 在我的 extent report, 我想添加测试用例总失败日志。 我怎么能这样做?

在Jenkins haedless浏览器中:org.openqa.selenium.WebDriverException:与远程浏览器通信时出错。 它可能已经死了

嗨,我正在使用Selenium Web驱动程序和Java在Jenkins无头浏览器上执行脚本。 运行两三个脚本之后我得到以下错误这个问题我观察者当我将在一次运行时运行多个脚本但是当我执行单个脚本时它不会通过任何错误。 请帮我解决这个问题。 以下是错误代码。 org.openqa.selenium.WebDriverException: Error communicating with the remote browser. It may have died. Build info: version: ‘2.51.0’, revision: ‘1af067d’, time: ‘2016-02-05 19:15:17’ System info: host: ‘devui1.pdx.aws’, ip: ‘127.0.0.1’, os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘2.6.32-573.7.1.el6.x86_64’, java.version: ‘1.7.0_95’ Driver info: driver.version: EventFiringWebDriver Session ID: b825d792-ea66-4422-9b19-fcbb29a0cb95 Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, nativeEvents=false, […]

如何使用testng标签进行烟雾回归测试

我有几种测试方法,我需要选择其中一些作为烟雾测试和其他回归测试。 我如何在Testng selenium中创建条件/依赖,因此烟雾测试将首先作为一组运行。 我可以为回归测试设置不同的Bamboo作业,只有在测试组通过后才能运行。 这是我的测试是: @Test(priority=1) public void test_1(){ —-} @Test(priority=2) public void test_2(){ —-} @Test(priority=3) public void test_3(){ —-} @Test(priority=4) public void test_4(){ —-} @Test(priority=5) public void test_5(){ —-} 这里,test_1到test_3是烟雾测试。 所以,如果他们通过其他人将被执行。 我怎样才能做到这一点?

我可以同时在不同的端口上运行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. […]

如何使用Selenium(Java)在浏览器中禁用JavaScript?

在我的function自动化中,我需要在浏览器中禁用JavaScript并运行流程。 如何禁用JavaScript? 试过firefox和Chrome的DesiredCapabilities。 DesiredCapabilities dc = new DesiredCapabilities(); dc.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, false) 和 DesiredCapabilities dc = new DesiredCapabilities(); dc.setJavascriptEnabled(false); 对于firefox,尝试过1)为firefox设置配置文件 2)添加附加组件 – noScript.xpi 3)profile.setPreference(“javascript.enabled”,false); 4)通过UI,尝试将标志 – “about:config”中的“javascript.enabled”更改为false。 在这里,打开firefox并给出“about:config”警告 – “这可能会使您的保修失效!”。 有一个按钮 – “我会小心的,我保证!” id – warningButton。 应单击此按钮以继续。 要单击此按钮,请使用driver.findElement(By.id(“warningButton”))。click(); 但它不起作用。 以上所有选项均无效。 任何建议都会有所帮助。

如何使用selenium从Dropdown中省略隐藏选项

如果我们使用selenium代码 Select sel = new Select(ele); eles = sel.getOptions(); 它将返回下拉选项的所有元素,我们可以获取值。 但是如果下拉列表的某些选项处于隐藏状态,并且如果我们使用相同的Select.getOptions(),它将返回包括隐藏选项在内的所有选项。 码: Administrator Instructor Student 从about代码中,Administrator和Instructor仅显示在下拉列表中,但Student不会显示在下拉列表中。 那么我们如何只从下拉列表中获取显示的选项呢?

如何通过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!

selenium:使用cssSelector看不到元素,而使用xpath可见

我试过java代码: driver.findElement(By.cssSelector(“input.only-numbers.ltr”)).sendKeys(“111”); 我收到一个错误: 线程“main”中的exceptionorg.openqa.selenium.ElementNotVisibleException:元素不可见 但当我将代码更改为xpath时,这项工作就完美了 driver.findElement(By.xpath(“html/body/section[10]/div/div[2]/form/div[1]/input”)).sendKeys(“111”); HTML代码: איפוס סיסמה תעודת זהות 为什么会发生这种情况?如何使用cssSelector修复?

如何通过selenium webdriver中的sendKeys传递变量?

我想在下面的程序中通过sendKeys传递浮点变量’f’。有人请让我知道吗? 截至目前,它正在投掷 “WebElement类型中的方法sendKeys(CharSequence …)不适用于参数”。 码: public static String isEditable(String s1) { f=Float.parseFloat(s1); System.out.println(f); boolean bool=webDriver.findElement(By.xpath(“expression”)).isEnabled(); if(bool) { if((f6)) { error=”Value must be between 0.00% and 6.00%”; System.out.println(error); } else { webDriver.findElement(By.xpath(“”expression”)).sendKeys(f); } } else { error=”Please enter a valid Number”; } return error; }

使用webdriver找不到元素

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