Tag: selenium webdriver

如何检查100%覆盖的WebElement是否可以与Selenium一起点击

我有两个具有绝对位置的div Visible later To be removed 和一些Javascript(这里没有显示)从DOM中删除4712一段时间(比如说2秒后)。 现在,在我的Selenium测试中,我想检查4711是否可点击。 从用户的角度来看,只有在删除4712后才能点击它。 所以我试过了 new WebDriverWait(browserInstance.getWebDriver(), 5).until(ExpectedConditions.elementToBeClickable(By.id(“4711”))); 但是,4711始终是可点击的(启用=真,显示=真),即使在删除4712之前也是如此。 有没有办法如何检查4711是否真的可以点击,也就是说,从用户的角度可以点击(理想情况下不使用Javascript)?

如何validationHTML5中的Constraint Validation API生成的消息中的文本?

我测试使用HTML5 Constraint Validation API生成错误弹出窗口的Web应用程序。 如何在selenium测试中validation弹出窗口中的文本? 我找不到合适的定位器。

线程“main”中的exceptionjava.lang.IllegalStateException:在Ubuntu上运行Selenium Test时,驱动程序可执行文件不存在

我在eclipse中尝试过这段代码: import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class auto { public static void main(String[] args) { System.setProperty(“webdriver.gecko.driver”, “/root/Desktop/jarselenium/geckodriver.exe”); WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.get(“https://www.easybooking.lk/login”); //driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS); } } 执行时我得到了这个错误: Exception in thread “main” java.lang.IllegalStateException: The driver executable does not exist: /root/Desktop/jarselenium/geckodriver.exe 如何在ubuntu中设置geckodriver位置?

Selenium – 存储会话数据

我在整个互联网上搜索,但我找到的答案都没有明确的解决方案。 我正在使用selenium webdriver和Java。 我的测试需要validation您何时保存登录信息并关闭浏览器并重新打开它,然后这些凭据保留并保存在新会话中。 因此,我想关闭当前会话并重新打开它以validationcookie是否仍然存在于页面上,但Selenium会删除所有存储的会话数据,因此测试用例将始终失败。 有没有办法阻止Selenium在关闭特定测试用例的浏览器后删除存储的会话数据? 当我运行它时,我得到一个没有这样的会话错误。

java.lang.NoSuchMethodError:com.google.common.base.Preconditions.checkState(ZLjava / lang / String;),包含Selenium,gradle和ChromeDriver

我正在尝试使用Selenium api和Gradle。 这是我的build.gradle依赖部分: dependencies { compile ‘com.google.api-client:google-api-client:1.23.0’ compile ‘com.google.oauth-client:google-oauth-client-jetty:1.23.0’ compile ‘com.google.apis:google-api-services-sheets:v4-rev506-1.23.0’ compile group: ‘org.seleniumhq.selenium’, name: ‘selenium-java’, version: ‘2.9.0’ compile group: ‘org.seleniumhq.selenium’, name: ‘selenium-chrome-driver’, version: ‘2.9.0’ } 我的selenium – Java代码: System.setProperty(“webdriver.chrome.driver”, “C:\\Program Files(x86)\\Google\\Chrome\\Application\\chrome.exe”); WebDriver driver = new ChromeDriver(); 代码工作正常,我可以打开Chrome浏览器。 但是,在build.gradle中,我使用的是2.9.0版本的selenium和chromedriver。 如果我尝试在2.9.0之后使用任何版本,它会在WebDriver driver = new ChromeDriver()中给出以下错误: 方法: Exception in thread “main” java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124) at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32) […]

Action类不适用于selenium 3.5.3

我想将元素从一个地方拖放到另一个地方。 所以,我正在使用动作类来实现我的function。 问题是我的代码执行成功,没有显示任何错误,但function目标没有实现。 我在firefox和chrome浏览器中尝试了相同的代码,但同样的问题在两个浏览器中都被复制了。 这是网站url 。 我试过的代码: driver.get(“http://www.seleniumeasy.com/test/drag-and-drop-demo.html”); driver.manage().window().maximize(); driver.findElement(By.xpath(“//div[@id=’todrag’]//span[contains(text(), ‘Draggable 1′)]”)); driver.findElement(By.xpath(“//div[@id=’todrag’]//span[contains(text(), ‘Draggable 2′)]”)); driver.findElement(By.xpath(“//div[@id=’todrag’]//span[contains(text(), ‘Draggable 3′)]”)); driver.findElement(By.xpath(“//div[@id=’todrag’]//span[contains(text(), ‘Draggable 4′)]”)); WebElement to = driver.findElement(By.xpath(“//div[@class=’w50 moveleft’]//div[@id=’mydropzone’]”)); String[] array_drag = new String[] {“Draggable 1”, “Draggable 2”, “Draggable 3”, “Draggable 4”}; for(int i=0; i<array_drag.length; i++) { WebElement from = driver.findElement(By.xpath("//div[@id='todrag']//span[contains(text(), '"+array_drag[i]+"')]")); Actions act = new Actions(driver); act.clickAndHold(from).build().perform(); […]

尝试通过ANT运行时,Selenium webdriver会抛出exception

我正在使用Eclipse运行我的UI自动化测试用例,它没有任何问题。 启动浏览器,执行测试用例,在Eclipse中执行时更新结果。 然而,当我试图通过ANT运行它时,它开始给我例外, java.lang.NoSuchMethodError: com.google.common.collect.Multimaps.transformValues(Lcom/google/common/collect/ListMultimap;Lcom/google/common/base/Function;)Lcom/google/common/collect/ListMultimap; 查看我项目的附件结构, 我的ANT文件(build.xml)供参考, Starting tests… <!– –> Some of these tests should have failed, see the file test.out for the details

无法使用Selenium WebDriver和Java打开IE11驱动程序实例

System.setProperty(“webdriver.ie.driver”,”C:\\Users\\IEDriverServer_Win32_2.45.0\\IEDriverServer.exe”); WebDriver driver = new InternetExplorerDriver(); driver.get(“http://xxx”); 执行上述代码时显示错误: 线程“main”中的exceptionorg.openqa.selenium.remote.SessionNotFoundException:启动Internet Explorer时出现意外错误。 保护模式设置对于所有区域都不相同。 必须将启用保护模式设置为所有区域的相同值(启用或禁用)。 (警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:1.33秒 有人可以建议解决这个问题吗?

WebElement #getScreenShotAs(OutputType.File)无法正常工作

我试图在Firefox浏览器代码中使用selenium webdriver 2.47.0版本中添加的WebElement#getScreenShotAs(OutputType.FILE)function public static void main(String[] args) throws IOException { WebDriver driver=new FirefoxDriver(); driver.manage().window().maximize(); driver.get(“http://automationpractice.com/index.php”); WebElement element=driver.findElement(By.cssSelector(“a[title=’Contact Us’]”)); System.out.println(element.getText()); element.getScreenshotAs(OutputType.FILE); File destination=new File(“Image.png”); FileUtils.copyFile(null, destination); } ..但我得到以下exception: Contact us Exception in thread “main” org.openqa.selenium.UnsupportedCommandException: Unrecognized command: GET /session/e796089b-1d64-4590-9157-a0716a57e399/screenshot/%7B4329461b-5e9c-4f8b-b589-ddc1af1d55a6%7D Command duration or timeout: 16 milliseconds Build info: version: ‘2.52.0’, revision: ‘4c2593cfc3689a7fcd7be52549167e5ccc93ad28’, time: ‘2016-02-11 11:22:43’ System […]

无法解析构造函数FirefoxDriver(org.openqa.selenium.firefox.FirefoxProfile)

有人可以帮我解决这段代码。 目前它会在第4行抱怨:webDriver = new FirefoxDriver(ff_ep_profiles)说它无法解析构造函数。 我需要加载我的扩展,因此我正在创建一个配置文件 FirefoxProfile ff_ep_profile = new FirefoxProfile(new File(“C:\\Users\\admin\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\81uy033g.FirefoxEP”)); FirefoxOptions option=new FirefoxOptions(); option.setProfile(ff_ep_profile); webDriver = new FirefoxDriver(ff_ep_profile);