标签: selenium-webdriver

org.openqa.selenium.WebDriverException:未知错误:调用函数结果缺少'value'

Sendkeys无法正常工作.请帮我解决这个问题..

WebElement username = driver.findElement(By.xpath("//*[@id='username']"));      
username.sendKeys("123456");
Run Code Online (Sandbox Code Playgroud)

安慰:

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'

  (Session info: chrome=65.0.3325.31)
  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.1.7601 SP1 x86) 
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds

Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'NEW-PC', ip: '192.168.0.103', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_161'
Run Code Online (Sandbox Code Playgroud)

司机信息:

org.openqa.selenium.chrome.ChromeDriver

Capabilities {acceptSslCerts: true, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: …
Run Code Online (Sandbox Code Playgroud)

java selenium google-chrome selenium-chromedriver selenium-webdriver

63
推荐指数
2
解决办法
8万
查看次数

Selenium - 如何等待页面完全加载

我正在尝试使用Java和Selenium WebDriver自动化一些测试用例.我有以下场景:

  • 有一个名为"产品"的页面.当我点击"产品"页面中的"查看详细信息"链接时,会出现一个包含该项目详细信息的弹出窗口(模式对话框).
  • 当我点击弹出窗口中的"关闭"按钮时,弹出窗口关闭,页面自动刷新(页面刚刚重新加载,内容保持不变).
  • 关闭弹出窗口后,我需要点击同一页面中的"添加项目"按钮.但是当WebDriver试图找到"添加项目"按钮时,如果互联网速度太快,WebDriver可以找到并单击该元素.

  • 但是如果互联网很慢,WebDriver会在页面刷新之前找到按钮,但只要WebDriver单击该按钮,页面就会刷新并StaleElementReferenceException发生.

  • 即使使用了不同的等待,所有等待条件也变为真(因为重新加载之前和之后页面中的内容相同),甚至在页面重新加载和StaleElementReferenceException 发生之前.

如果Thread.sleep(3000);在单击"添加项目"按钮之前使用测试用例,则工作正常.这个问题还有其他解决方法吗?

java selenium-webdriver

62
推荐指数
3
解决办法
20万
查看次数

使用Selenium WebDriver和Java切换选项卡

使用Selenium WebDriver和JAVA.我试图自动化一个功能,我必须打开一个新的选项卡在那里做一些操作,然后回到上一个选项卡(父).我使用了开关手柄,但它不起作用.还有一个奇怪的事情是两个标签有相同的窗口句柄,因此我无法在标签之间切换.

但是,当我尝试使用不同的Firefox窗口时,它可以工作,但是对于标签,它不起作用.

请帮我,如何切换标签.或者如何在不使用窗口句柄的情况下切换标签,因为在我的情况下,窗口句柄与两个标签相同.

(我观察到当你在同一个窗口中打开不同的标签时,窗口句柄保持不变)

java testing selenium automation selenium-webdriver

61
推荐指数
5
解决办法
23万
查看次数

如何在Selenium WebDriver中设置浏览器宽度和高度?

我正在使用Selenium WebDriver for Python.我想要实例化具有特定宽度和高度的浏览器.到目前为止,我能得到的最接近的是:

driver = webdriver.Firefox()
driver.set_window_size(1080,800)
Run Code Online (Sandbox Code Playgroud)

哪个有效,但在创建后设置浏览器大小,我希望它在实例化时设置.我猜测有一种方法:

profile = webdriver.FirefoxProfile();
profile.set_preference(foo, 1080)
driver = webdriver.Firefox(profile)
Run Code Online (Sandbox Code Playgroud)

但我不知道foo会是什么,我无法弄清楚文档的位置.

Q1:有没有办法在实例化时设置宽度/高度?

Q2:列出可用的所有密钥的参考文档在哪里profile.set_preference

python selenium screen-resolution selenium-webdriver

61
推荐指数
5
解决办法
8万
查看次数

如何从Selenium获取元素的属性?

我在Python中使用Selenium.我想得到.val()一个<select>元素,并检查它是我期望的.

这是我的代码:

def test_chart_renders_from_url(self):
    url = 'http://localhost:8000/analyse/'
    self.browser.get(url)
    org = driver.find_element_by_id('org')
    # Find the value of org?
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?Selenium文档似乎有很多关于选择元素但没有关于属性的内容.

python selenium webdriver getattribute selenium-webdriver

61
推荐指数
3
解决办法
10万
查看次数

Selenium Grid:MaxSessions vs MaxInstances

我想知道是否有人可以对一个Selenium让我们有点头疼的问题有所了解.

我们困惑的意义MaxSessionMaxInstances硒电网.我们认为这MaxSession是可以在单个节点上运行的测试会话的总数.我们还认为MaxInstances测试可以打开的浏览器总数.

或者是MaxInstances节点可用的浏览器总数?

我们使用的命令是:

java -Xrs -jar selenium-server.jar -role node -port 44506 -hub http://localhost:44500
/grid/register -firefoxProfileTemplate SeleniumProfile -timeout 300000 -browser 
"browserName=firefox,maxInstances=10,platform=ANY,seleniumProtocol=WebDriver" -browser 
"browserName=chrome,maxInstances=10,platform=ANY,seleniumProtocol=WebDriver"
Run Code Online (Sandbox Code Playgroud)

我们认为我们使用节点的方式(上面)默认是5个并发测试会话.

每个测试都有20个可用的浏览器吗?

或者每个测试会话是否共享池中的20个浏览器(10 chrome/10 FF) - 与其他测试会话?

selenium selenium-grid selenium-webdriver

60
推荐指数
2
解决办法
5万
查看次数

如何使用Java中的Selenium WebDriver上传文件

任何人都可以让我知道如何使用Selenium通过Java代码上传文件?

当我点击应用程序中的按钮时,它会在新窗口中打开,我可以使用它来选择上传文件.由Silverlight(C#)开发的浏览按钮.

java upload selenium-webdriver

60
推荐指数
3
解决办法
14万
查看次数

如何修复Selenium WebDriverException:在我们连接之前,浏览器似乎已经退出了?

我已经在我的centos6.4服务器上安装了firefox和Xvfb来使用selenium webdriver.

但是,当我运行代码时,我收到了一个错误.

from selenium import webdriver
browser = webdriver.Firefox()
Run Code Online (Sandbox Code Playgroud)

错误

selenium.common.exceptions.WebDriverException: Message: 
'The browser appears to have exited before we could connect. The output was: None'
Run Code Online (Sandbox Code Playgroud)

我在stackoverflow上读了一些相关的页面,有人建议删除tmp文件夹中的所有文件,所以我做到了.但是,它仍然无效.

有人可以帮我一个忙吗?

先感谢您!

编辑

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/site-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
    self.binary, timeout),
  File "/usr/local/lib/python3.4/site-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/local/lib/python3.4/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 64, in launch_browser
    self._wait_until_connectable()
  File "/usr/local/lib/python3.4/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 103, in _wait_until_connectable
    self._get_firefox_output())
selenium.common.exceptions.WebDriverException: Message: 'The browser appears to have exited     before …
Run Code Online (Sandbox Code Playgroud)

python selenium webdriver selenium-webdriver

60
推荐指数
6
解决办法
7万
查看次数

webdriver.get()和webdriver.navigate()之间的区别

get()navigate()方法有什么区别?是否有任何此方法或其他方法等待加载页面内容?我真正需要的是像selenium WaitForPageToLoadWaitForPageToLoad webdriverwebdriver` 这样的东西.

有什么建议?

java webdriver time-wait selenium-webdriver

59
推荐指数
3
解决办法
16万
查看次数

使用Java捕获Selenium WebDriver的浏览器日志

有没有办法在使用Selenium运行自动化测试用例时捕获浏览器日志?我发现了一篇关于如何在Selenium中捕获JavaScript错误的文章.但这仅适用于Firefox,仅适用于错误.我想得到所有的控制台日志.

java selenium selenium-webdriver

59
推荐指数
5
解决办法
8万
查看次数