- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否可以将 headless 浏览器与 Locust 集成?我需要我的负载测试来处理在每次页面加载时触发额外请求的客户端脚本。
最佳答案
这是一个老问题,但我现在遇到了它,并在“realbrowserlocusts”(https://github.com/nickboucart/realbrowserlocusts)中找到了解决方案 - 它使用 selenium 添加了“对 Locust.io 负载测试的真实浏览器支持”。
如果您使用其中一个类(FirefoxLocust、ChromeLocust、PhantomJSLocust)而不是 HttpLocust 作为您的 Locust 用户类
class WebsiteUser(HeadlessChromeLocust):
然后在您的 TaskSet 中,self.client 成为 selenium WebDriver 的一个实例。
我的一个缺点是 webdriver(不像 HttpLocust 中的内置客户端)不知道“host”,它强制在 TaskSet 中使用绝对 URL 而不是相对 URL,并且在以下情况下使用相对 URL 真的很方便使用不同的环境(本地、开发、暂存、生产等)。但是有一个简单的解决方法:从 realbrowserlocusts 的蝗虫之一继承并将“主机”传递给 WebDriver 实例:
from locust import TaskSet, task, between
from realbrowserlocusts import HeadlessChromeLocust
class UserBehaviour(TaskSet):
@task(1)
def some_action(self):
# self.client is selenium WebDriver instance
self.client.get(self.client.base_host + "/relative/url")
# and then for inst. using selenium methods:
self.client.find_element_by_name("form-name").send_keys("your text")
# etc.
class ChromeLocustWithHost(HeadlessChromeLocust):
def __init__(self):
super(ChromeLocustWithHost, self).__init__()
self.client.base_host = self.host
class WebsiteUser(ChromeLocustWithHost):
screen_width = 1200
screen_height = 1200
task_set = UserBehaviour
wait_time = between(5, 9)
============
2020 年 9 月 5 日更新:
我在 2020 年 3 月发布了这个解决方案,当时 Locust 的主要版本为 0。从那时起,在 2020 年 5 月,他们发布了 1.0.0 版,其中进行了一些向后不兼容的更改(其中之一 - 将 StopLocust 重命名为 StopUser) . realbrowserlocusts 有一段时间没有更新了,还没有更新到可以与 locust >=1 一起使用。
虽然有一个解决方法。当 locust v1.0.0 发布时,以前的版本以新名称发布 - locustio,最新版本为 0.14.6,因此如果您安装“locustio== 0.14.6”(或“locustio<1”),那么使用 realbrowserlocusts 的解决方案仍然有效(我刚刚检查过)。 (参见 https://github.com/nickboucart/realbrowserlocusts/issues/13)。
你必须限制 locustio 的一个版本,因为它拒绝在没有它的情况下安装:
pip install locustio
...
ERROR: Command errored out with exit status 1:
...
**** Locust package has moved from 'locustio' to 'locust'.
Please update your reference
(or pin your version to 0.14.6 if you dont want to update to 1.0)
关于locust - headless 浏览器和 locust.io,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32890209/
我正在尝试使用 firefox headless 在 headless (headless) redhat linux 构建机器上运行 selenium 测试。我创建驱动程序的方法如下所示: priv
关于这个主题有很多东西可以找到,但无法弄清楚。我需要滚动到(不太长)无限滚动页面的末尾。我有 2 个选项可以使用 chrome 非 headless (headless)但似乎不能 headless
我在远程服务器上运行 OpenFOAM,基本上设法通过 paraview 的 pvserver 可视化结果 as described here .然而,在连接后,客户端产生 Server DISPLA
我想在 headless 模式下截取 Android 设备的屏幕截图,也就是说我是这样创建的: echo no | /opt/android/android-sdk-linux/tools/andro
主要区别在于,基于GUI和非GUI(Headless)执行。 我正在寻找所有Headless浏览器之间的差异,但是很遗憾,我没有找到任何差异。我一个接一个地经历,这使我更加困惑。如果有人可以分享具有差
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭10 年前。 Improve th
我需要在没有 X 服务器的情况下执行 java 图像裁剪和调整大小。 我尝试了几种方法。下面的第一种方法有效,但输出了一个相当难看的调整大小的图像(可能使用最近邻算法来调整大小: static Buf
过去几天我一直在使用 Selenium、Tor 和 Firefox 作为多个任务的组合。我已经设法用 Python 编写了一个简单的脚本,它通过 Selenium 控制 Firefox,而 Firef
我正在使用 pygame 的操纵杆 api 在 headless (headless)系统上对我的项目使用操纵杆,但是 pygame 需要一个“屏幕”,所以我设置了一个虚拟视频系统来克服这个问题。它工
我想使用 headless firefox 在 macos 上捕获网页的图像。 这是我执行的命令:/Applications/Firefox.app/Contents/MacOS/firefox-bi
我正在使用带有 headless-chromium-php 的 google chrome headless (headless)浏览器 导航到某些网站,但它总是被验证码检测到 我尝试使用此 plug
是否有可能使用 Octave headless。 像这样的东西 octave result.txt 最佳答案 使用 octave --silent --eval 5+4 > result.txt 你会
我目前正在尝试在 headless (headless)模式下运行应用程序,我定义了后台回调: void callbackInBackground() { // Invoked from the s
我正在使用LibGDX headless backend运行jUnit测试。这在某些测试中效果很好,但是如果我尝试创建new Texture('myTexture.png');,则会收到NullPoi
我想在这个页面上使用 Selenium:https://www.avis.com/en/home 如果没有 headless (headless)模式,该代码一切正常: import requests
在Jasmine headless (headless)Webkit中运行测试时,我遇到了一个简单的TypeError: 'undefined' is not an object失败。但是没有提示在哪
我负责测试一个大量使用 AJAX 的企业 Web 应用程序。我需要构建一个系统,允许在没有人工干预的情况下连续运行测试。目前我最感兴趣的是负载测试,但我希望用于生成负载的相同脚本用于功能测试。 目前用
TL; DR:我可以配置一个容器来原生访问VGA,以覆盖主机视频输出吗? 我正在考虑处置低功耗的XenServer(以前为ESXi)白盒以设置docker最小安装(例如CoreOS,RancherOs
我正在尝试 headless (headless)运行我的测试,并将我的两个测试套件分片以并行运行它们。在我的本地计算机上,它们并行运行,但在这种 headless (headless)设置中,它们一
仍在尝试为大型大学项目(RCP 产品)建立 headless (headless)构建。 每个 Eclipse 用户都知道以下手动功能:“文件 --> 导入 --> 将现有项目导入工作区”以及“构建工
我是一名优秀的程序员,十分优秀!