更新0429-完整的docker图像,你可以拉和玩,其中有Windows、docker、Chrome、Firefox和所有测试。GitHub repo上的Dockerhub链接和说明-https://github.com/jhealy/aspnet45-docker-selenium .
我的硒。Chromedrive c#测试失败,尝试获取远程WebDriver服务器时超时。主要信息似乎是
向远程WebDriver服务器发送的URL的HTTP请求http://localhost:49164/session60秒后超时
我使用dockerfile设置应用程序并将我的应用程序复制到其中。我可以通过powershell/wget在docker文件的外部和内部点击应用程序。
下面的部分包括Dockerfile、配置命令,以及讨厌的小错误屏幕的完整输出。
码头文件
# extending the `microsoft/aspnet` image.
FROM microsoft/aspnet
# COPY ./bin/Publishoutput/ /inetpub/wwwroot
COPY ./MvcHelloWorld45/bin/Release/Publish/ /inetpub/wwwroot
RUN mkdir seleniumtests
COPY ./SeleniumDockerTest/bin/Release/ /seleniumtests
# choco chrome takes a bit
RUN echo 'Downloading chocolatey...'
RUN powershell -Command Install-PackageProvider -name chocolatey -Force
RUN powershell -Command Set-PackageSource -Name chocolatey -Trusted
RUN powershell -Command Get-PackageSource
RUN echo 'Install Chrome via chocolatey...'
RUN powershell -Command Install-Package GoogleChrome -MinimumVersion 74
供应
# build and run my image in local machine powershell
docker build -f dockerfile -t aspnet45 .
Docker run -d --name aspnet45run -p 5000:80 aspnet45
# verify web server is up and running
curl http://localhost:5000
# powershell into remote machine
Docker exec -it <first couple unique chars of ps> powershell
# inside remote machine make sure we can hit it
curl http://localhost -UseBasicParsing
# run test which works fine outside but blows up inside container
cd \seleniumtests
.\SeleniumDockerTest.exe
使用NUGET SELENIUM. WEBDRIVER. CH74铬的C#硒测试
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace SeleniumDockerTest
{
class Program
{
static IWebDriver m_driverGC;
static void Main(string[] args)
{
string targetUrl = @"http://localhsot";
try
{
ChromeOptions option = new ChromeOptions();
option.AddArgument("--headless");
option.AddArgument("--dns-prefetch-disable");
option.AddArgument("--disable-features=VizDisplayCompositon");
using (m_driverGC = new ChromeDriver(option))
{
m_driverGC.Navigate().GoToUrl(targetUrl);
string msg = "hello world";
Console.WriteLine($"CheckWebElements('{msg}')={CheckWebElements(msg)}");
m_driverGC.Close();
m_driverGC.Quit();
}
}
catch ( Exception ex )
{
Console.WriteLine("!!!error:" + ex.ToString());
}
}
static public bool CheckWebElements(string msg)
{
if (string.IsNullOrWhiteSpace(msg)) return false;
msg = msg.ToLower();
return m_driverGC.FindElement(By.Id("myH1")).Text.ToLower().Contains(msg);
}
}
}
错误块
[Target Url] =[http://localhost] beginning chrome tests [chrome options:] =[--headless --window-size=1920,1080 --disable-features=VizDisplayCompositor --disable-gpu] Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 49160 Only local connections are allowed. Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code. [0430/150246.015:ERROR:network_change_notifier_win.cc(156)] WSALookupServiceBegin failed with: 0 [0430/150246.046:ERROR:audio_device_listener_win.cc(46)] RegisterEndpointNotificationCallback failed: 80070424 DevTools listening on ws://127.0.0.1:49163/devtools/browser/853e1883-9876-4fad-9dcc-6bf74c060baf [0430/150246.253:ERROR:network_change_notifier_win.cc(156)] WSALookupServiceBegin failed with: 0 !!!!!!!!!!!!!!!!!!!!!!!!!!! [exception caught] =[OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:49160/session timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest.GetResponse() at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo) --- End of inner exception stack trace --- at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo) at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options) at SeleniumDockerTest.Program.DoChromeTests() in C:\dev\docker-selenium-aspnet45.git\SeleniumDockerTest\Program.cs:line 53] !!!!!!!!!!!!!!!!!!!!!!!!!!! Hit any key to continue
PS C:\seleniumtests> .\seleniumdockertest.exe http://localhost [Target Url] =[http://localhost] firefox tests commencing BrowserExecutableLocation=C:\Program Files\Mozilla Firefox\firefox.exe -headless 1556651472894 mozrunner::runner INFO Running command: "C:\\Program Files\\Mozilla Firefox\\firefox.exe" "-marionette" "-headless" "-foreground" "-no-remote" "-profile" "C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\rust_mozprofile.hlVVZVvFg66U" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!error:OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:49158/session timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out. at System.Net.HttpWebRequest.GetResponse() at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo) --- End of inner exception stack trace --- at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo) at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxOptions options) at SeleniumDockerTest.Program.DoFirefoxTests() in C:\dev\docker-selenium-aspnet45.git\SeleniumDockerTest\Program.cs:line 150 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! firefox tests completed Hit any key to continue
谢谢你的关注!
修复这个特定错误的方法是将web套接字安装到我的docker映像中。
Dockerfile如下:
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8
RUN powershell -Command Add-WindowsFeature Web-WebSockets
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
RUN powershell -Command choco install googlechrome -y
RUN powershell -Command choco install firefox -y
问题内容: 在我的JMeter测试中,如果有任何错误,我想触发HTTP请求以在系统上发布消息,以进一步关注。我在这里可以做什么?邮件可视化工具可以很好地通过电子邮件报告错误。我想做同样的事情,但是要通过HTTP请求。我正在使用jmeter 3.2。 问题答案: 您可以执行以下操作: 在HTTP Request采样器之后添加If Controller,并将以下代码放入“条件”区域: 将SMTP Sa
这是我的第一个问题。我对API上的http请求有问题。当我发出请求时,控制台上会显示以下错误: 异常:找不到不同类型'对象'的支持对象'[对象对象]'。NgFor仅支持绑定到Iterable,如Array。 每个文件的内容如下: 靴子ts 应用程序。组成部分ts peli.service.ts peli.ts 以及我从请求中收到的JSON文件(输入-蜘蛛侠): 我不知道问题出在哪里,一切似乎都很好
HTTP/1.1 408 REQUEST_TIMEOUT内容-长度:0连接:关闭 已关闭 --------------------------------------------------------------------------------------- 它会导致请求超时。如果我使用curl命令,它是成功的。 请求超时的原因是什么?
我正在使用以下版本的VSCode: 使用Python扩展version。唯一安装的PIP是: 我试图在vscode中调试python测试,在调试控制台中出现以下错误: 测试本身在终端上运行良好。换句话说,找不到“缺失”模块没有问题。例子: 我启动调试器的方式是单击给定测试的链接。例子: 下面是配置: 有人知道我在配置方面缺少什么吗?
这一条给出: 这个: 我想做的是避免为所有测试编写完整的jsons,如果我可以跳过所有“”和{},将会更快。我的方法正确吗?
我最近编写了一个具有一些Internet连接的应用程序。所有进程在模拟器中运行良好,但在Android Studio上,它会抛出一个,并带有以下堆栈跟踪。 快速的网络搜索表明,这个问题可能与回复标题有关,但我不确定为什么/如何防止这个错误。