小编iam*_*p89的帖子

设置输入值而不是sendKeys() - selenium webdriver nodejs

我有一个长串测试,sendKeys()需要太长时间.当我试图设置text程序崩溃的值时.我知道Selenium sendKeys()是测试实际用户输入的最佳方式,但对于我的应用程序,它需要花费太多时间.所以我试图避免它.

有没有办法立即设置价值?

看到这个简单的例子:

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
   withCapabilities(webdriver.Capabilities.chrome()).
      build();

driver.get('http://www.google.com');

// find the search input field on google.com
inputField = driver.findElement(webdriver.By.name('q'));

var longstring = "test"; // not really long for the sake of this quick example

// this works but is slow
inputField.sendKeys(longstring);

// no error but no values set
inputField.value = longstring;

// Output: TypeError: Object [object Object] has no method 'setAttributes'

inputField.setAttributes("value", longstring);
Run Code Online (Sandbox Code Playgroud)

javascript selenium node.js selenium-webdriver

33
推荐指数
3
解决办法
15万
查看次数

11
推荐指数
2
解决办法
1万
查看次数

如何使用xpath从表中获取表数据

XPATH可以使用什么查询来获取<td>html表中每行的第1和第3个标记的值.

XPATH我用过的查询是

/table/tr/td[1]|td[3].

这仅返回<td>表中每行的第一个标记中的值.

我希望从下表中得到值bob,19,jane,11,Cameron和32.但我只得到鲍勃,简,卡梅伦.

<table>
<tr><td>Bob</td><td>Male</td><td>19</td></tr>
<tr><td>Jane</td><td>Feale</td><td>11</td></tr>
<tr><td>Cameron</td><td>Male</td><td>32</td></tr>
</table>
Run Code Online (Sandbox Code Playgroud)

xpath

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

对 matplotlib 线图使用颜色图

我想使用反向 Spectral colormap

https://matplotlib.org/examples/color/colormaps_reference.html

对于线图。

这适用于十六进制图:

color_map = plt.cm.Spectral_r
image = plt.hexbin(x,y,cmap=color_map)
Run Code Online (Sandbox Code Playgroud)

但是当我这样做的时候

ax1.plot(x,y, cmp=color_map)
Run Code Online (Sandbox Code Playgroud)

这给了我::

AttributeError: 未知属性 cmap

请注意,我只想设置colormap并让matplotliob其余的工作;即我不想color=' argument在 .plot 命令中有一个。

python plot matplotlib colormap

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

6
推荐指数
1
解决办法
3万
查看次数

使用带有 Python 的 Selenium Webdriver 在 Headless chrome 浏览器上运行脚本时发生超时错误

当我在Headless Chrome Broswer (Webdriver + Selenium )上运行 python 脚本测试网站时,经常会出现超时错误,我发现问题是脚本通过.click().send_keys()方法与浏览器交互时发生的。谁能知道这是什么类型的问题?有时它工作正常,但有时我有超时错误。请给出相同的解决方案

堆栈跟踪:

 15:01:48,194 root:ERROR: ERROR occurred: Message: timeout
   (Session info: headless chrome=60.0.3112.101)
   (Driver info: chromedriver=2.31.488763 
   (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7601 SP1 
    x86)

    Traceback (most recent call last):
  File "c:\autotest\x.py", line 148, in main
    func(nik)
  File "c:\autotest\lib\support.py", line 126, in wrapper
    raise ret
  File "c:\autotest\lib\support.py", line 113, in newFunc
    res[0] = func(*args, **kwargs)
  File "c:\autotest\testcases\1001.py", line 15, in testcase
    "documents_approved ASC", generateError=True)  
  File "c:\autotest\lib\support.py", line 51, in wrapper
    f_result = …
Run Code Online (Sandbox Code Playgroud)

python selenium google-chrome headless-browser selenium-webdriver

6
推荐指数
1
解决办法
3432
查看次数

Android BackupManager完整数据备份未获得同意

我正在使用bmgr测试自动备份,但无法使其正常工作.

我已经进入allowBackup="true"了清单,当然它已经在设备上启用了.

有谁知道是什么INELIGIBLE_DOLLY_CONSENT

09-12 19:16:27.163 783-11562/? I/PFTBT: Initiating full-data transport backup of com.xxxxxxxxx.xxxxx
09-12 19:16:27.166 1371-1640/? I/Backup: [GmsBackupTransport] Attempt to do full backup on com.xxxxxxxxx.xxxxx
09-12 19:16:27.173 1371-1640/? W/Backup: [EligibilityFilter] Rejecting backup of com.com.xxxxxxxxx.xxxxx. Full data backup does not have consent
09-12 19:16:27.173 1371-1640/? W/Backup: [GmsBackupTransport] Rejecting package com.xxxxxxxxx.xxxxx for full backup because ineligible (INELIGIBLE_DOLLY_CONSENT).
09-12 19:16:27.175 783-11562/? I/PFTBT: Transport rejected backup of com.xxxxxxxxx.xxxxx, skipping
09-12 19:16:27.175 783-11562/? I/PFTBT: Full backup completed.
Run Code Online (Sandbox Code Playgroud)

backup android adb

6
推荐指数
1
解决办法
435
查看次数

未初始化的常量Selenium :: WebDriver :: Chrome :: Options(NameError)

需要执行以下代码集。请参考我的代码:

Capybara.register_driver :logging_selenium_chrome do |app|
  caps = Selenium::WebDriver::Remote::Capabilities.chrome(loggingPrefs:
  {browser: 'ALL'})
  browser_options = ::Selenium::WebDriver::Chrome::Options.new()
  Capybara::Selenium::Driver.new(app, browser: :chrome, options: 
  browser_options, desired_capabilities: caps)
end
Run Code Online (Sandbox Code Playgroud)

但不断

未初始化的常量Selenium :: WebDriver :: Chrome :: Options(NameError)

任何人都不知道可能是什么原因造成的!!!

ruby selenium google-chrome capybara

6
推荐指数
2
解决办法
3012
查看次数

如何使用&nbsp;搜索元素 硒中的符号

首先我认为该元素是空的,但我发现它包含:

<div class="Tips">&nbsp;</div>
Run Code Online (Sandbox Code Playgroud)

是的NO-BREAK SPACE.我想抓住这个div,xpath但我无法做到.xpath你用的是什么

text()='?'
Run Code Online (Sandbox Code Playgroud)

selenium xpath robotframework

4
推荐指数
1
解决办法
3222
查看次数

在Python中,如何检查Selenium WebDriver是否退出?

以下是示例代码:

from selenium import webdriver

driver = webdriver.Firefox()
Run Code Online (Sandbox Code Playgroud)

(这里由于某种原因窗口被关闭)

driver.quit()
Run Code Online (Sandbox Code Playgroud)

回溯(最近一次调用最后):文件“”,第1行,文件“/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py”,第183行,退出RemoteWebDriver .quit(self) 文件“/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py”,第 592 行,退出 self.execute(Command.QUIT) 文件“/usr /local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py”,第297行,在执行self.error_handler.check_response(response)文件“/usr/local/lib/python2.7/ dist-packages/selenium/webdriver/remote/errorhandler.py”,第 194 行,在 check_response 中引发 exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException:消息:尝试在不建立连接的情况下运行命令

有没有办法检查 webdriver 实例是否处于活动状态?

python selenium

3
推荐指数
1
解决办法
7492
查看次数

NSFont 和 UIFont 有什么区别

在搜索问题的解决方案时,我发现了NSFontUIFont

两者之间的基本区别是什么以及我们何时应该使用?

uifont ios nsfont

2
推荐指数
1
解决办法
1435
查看次数

Python:如何使用 Selenium 打印所有源代码

driver.page_source不要返回所有的源代码。它只是详细地打印了部分代码,但它遗漏了大部分代码。我怎样才能解决这个问题?

这是我的代码:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
  def htmlToLuna():
  url ='https://codefights.com/tournaments/Xph7eTJQssbXjDLzP/A'
  driver = webdriver.Chrome('C:\\Python27\\chromedriver\\chromedriver.exe')
  driver.get(url)
  web=open('web.txt','w')
  web.write(driver.page_source)
  print driver.page_source
  web.close()

print htmlToLuna()
Run Code Online (Sandbox Code Playgroud)

python selenium selenium-webdriver

1
推荐指数
1
解决办法
4862
查看次数