Tag: selenium

Selenium – 单击切换元素

我对selenium很感兴趣。 基本上我想单击以下元素来切换元素: 它变为 : 之后我只想填写表格并测试其输出。 我为单击此元素编写的方法: public void clickAtListView() { WebElement listView = driver.findElement(By.xpath(“//div[@class=’view-icon fadeIn’]”)); listView.click(); } 但是,我得到了: Exception in thread “main” org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with Command duration or timeout: 50 milliseconds 任何建议为什么我得到这个例外? 我感谢你的回答! UPDATE 在我看来,当我放入Thread.sleep(10000);时会显示list元素Thread.sleep(10000); 之前: 但是,我仍然得到例外;(

我得到一个“线程中的exception”主“java.lang.NoClassDefFoundError:org / openqa / selenium / WebDriver”

我添加了selenium-standalone.jar和selenium-java.jar但是在运行基本程序时我仍然遇到以下exception, 线程“main”中的exceptionjava.lang.NoClassDefFoundError:org / openqa / selenium / WebDriver(错误名称:org / openqa / selenium / Webdriver),位于java.lang.ClassLoader的java.lang.ClassLoader.defineClass1(Native Method)中。 java.securityClassLoader.defineClass(URLClassLoader.java:449)中的java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)中的defineClass(ClassLoader.java:791),java.net.URLClassLoader.access $ 100(URLClassLoader。 java:71)at java.net.URLClassLoader $ 1.run(URLClassLoader.java:361)at java.net.URLClassLoader $ 1.run(URLClassLoader.java:355)at java.security.AccessController.doPrivileged(Native Method)at java位于java.lang上的sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java :)的java.lang.ClassLoader.loadClass(ClassLoader.java:423)中的.net.URLClassLoader.findClass(URLClassLoader.java:354)。 ClassLoader.loadClass(ClassLoader.java:356)位于java.lang.Class的java.lang.Class.privateGetDeclaredMethods(Class.java:2442)的java.lang.Class.getDeclaredMethods0(Native Method)中。 getMethod0(Class.java:2685)ata.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:488)at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java)中的java.lang.Class.getMethod(Class.java:1620) :480) 请提供解决方案以及解决此问题的正确步骤

通过selenium在firefox中打开私有模式

其实我想通过selenium打开一个隐身/私有模式的firefox浏览器,但每次我试过它都是在正常模式下打开firefox。 经过一些谷歌搜索我得到了这个代码,我曾经通过selenium在firefox中打开私有模式,但它无法正常工作。 FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference(“browser.privatebrowsing.autostart”, true); WebDriver driver = new FirefoxDriver(firefoxProfile); driver.get(“http://www.google.com”); 有人可以帮忙怎么做?

使用BrowserMobProxy,Selenium,Firefox,marionette / gecko获取请求和响应

我正在尝试使用BMP的RequestFilter和ResponseFilter获得响应和请求。 但是,当网页加载时,控制台中不会打印任何内容。 其他一切似乎都有效。 也许BMP不是在看GeckoDriver? 我使用的是Firefox 50.0,BrowserMobProxy 2.1.2,Selenium 3.0.1和GeckoDriver 0.11.1 测试代码如下。 有人可以帮帮我吗? 非常感谢你! BrowserMobProxy server = new BrowserMobProxyServer(); server.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT); server.start(); int port = server.getPort(); server.addRequestFilter((request, content, info) -> { String q = URLDecoder.decode(info.getOriginalUrl(), “UTF-8”); System.out.println(“Request: “+q); return null; }); server.addResponseFilter((response, content, info) -> { String type = response.headers().get(“Content-Type”); System.out.println(“Response: “+info.getOriginalRequest()); System.out.println(type); }); Proxy proxy = […]

保存Selenuim Web Driver生成的firefox配置文件

我使用Selenium WebDriver和firefox。 每次selenium在temp文件夹中为firefox生成新的anoniumus配置文件,并在退出后删除它。 我需要这个档案。 我怎么才能得到它? 存储的Fe配置文件 C:\Documents and Settings\Developer\Local Settings\Temp\anonymous5583304190515426768webdriver-profile 关闭WebDriver后 driver.quit(); 配置文件将被删除,但它已被记录,我希望在下一次迭代中使用它,方法是使用它启动WebDriver: FirefoxDriver driver = new FirefoxDriver(new FirefoxProfile(profileFolder)); 是否有可能保存配置文件没有肮脏的黑客攻击,如驱动程序工作时应对整个文件夹(我不确定它是否工作,因为在Windows中,文件夹被锁定而firefox启动)? 可能在Selenium中存在一些API吗?

在通过Jenkins作为Windows服务运行时无法最大化浏览器

通过Windows运行测试脚本时,由于脚本失败,无法最大化浏览器窗口, 尝试了这个线程中提到的所有可能的方法,但没有使用无法通过Jenkins中的Selenium为Chrome浏览器设置大小(增加大小)? 有没有办法最大化窗口? 任何帮助表示赞赏。 提前致谢。

如何使用Java在Selenium WebDriver中禁用Chrome插件

Chrome插件弹出 当我为此应用程序执行自动化代码时,将显示上面的弹出窗口。 现在我需要知道如何使用Java在Selenium WebDriver中禁用PDF Viewer插件。 这就是我现在正在使用的不起作用的地方。 DesiredCapabilities capabilities = DesiredCapabilities .chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments(new String[] { “test-type” }); options.addArguments(new String[] { “disable-extensions” }); String pluginToDisable = “Chrome PDF Viewer”; options.addArguments(“plugins.plugins_disabled”, pluginToDisable); capabilities.setCapability(“chrome.binary”, chromeDriver.getAbsolutePath()); capabilities.setCapability(ChromeOptions.CAPABILITY, options); options.addArguments(“–lang=en-gb”); GlobalVars.driver = new ChromeDriver(capabilities);

Chrome版本44在selenium测试中存在一些问题

我正在使用Selenium和Chrome编写测试,昨天当我的Chrome从43更新到44时,我的测试遇到了action.sendkey(“arrow.down”)等问题。 我尝试卸载Chrome并安装Chrome 43,但是一旦我这样做就将其自我更新为44! 我也尝试过chromedriver 2.16,但它也没有用。 我该如何解决?

什么是用于webdriver和浏览器之间通信的机制

任何人都可以解释浏览器和网络驱动程序之间的通信方式? webdriver对象如何在浏览器中读取和识别html元素? 那为什么webdriver对象和浏览器之间的关系以及如何构建关系浏览器和webdriver对象? driver = new FirefoxDriver(); driver.findElements(By.id(“element”));

如何使用selenium获取android native app的x,y坐标

如何使用selenium java web驱动程序获取android native app的x,y坐标。 我正在使用appium。 我的应用程序打开android图库。 由于uiautomatorviewer没有显示它的布局。 我无法点击图片。 看起来像moveToElement,mouseMoveAt等仅适用于浏览器。 本机应用程序有哪些可用选项。