3我正在使用selenium-server-standalone-2.33.0.jar来启动selenium测试套件.我有一个测试套件,在firefox和Internet Explorer中运行得非常好.当我尝试在Google Chrome中运行它时,它对当前用户运行正常.当我尝试从本地系统用户运行测试(打开以本地系统用户身份运行的命令窗口)时,测试失败,给我一个Windows注册表异常.这是我试图运行的命令:
java -jar selenium-server-standalone-2.33.0.jar -port 5885 -htmlsuite "*googlechrome" "http://www.google.com" "TestSuite.html" "results.html"
Run Code Online (Sandbox Code Playgroud)
这是我得到的例外:
HTML suite exception seen:
java.lang.RuntimeException: org.openqa.selenium.os.WindowsRegistryException: Problem while managing
the registry, OS Version '6.1', regVersion1 = false
Build info: version: '2.33.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_38'
Driver info: driver.version: unknown
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.createBrowserLauncher(
BrowserLauncherFactory.java:175)
at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.getBrowserLauncher(Bro
wserLauncherFactory.java:109)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.getBrowserLauncher(HTMLLauncher.java:7
9)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:139)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:198)
at org.openqa.selenium.server.SeleniumServer.runHtmlSuite(SeleniumServer.java:630)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:305)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:245)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:54)
Caused by: org.openqa.selenium.os.WindowsRegistryException: Problem …
Run Code Online (Sandbox Code Playgroud) 用户帐户的nuget缓存通常位于
C:\Users\<user>\AppData\Local\NuGet\Cache
.
但是LOCAL SYSTEM帐户在哪里可以找到?这个特殊用户没有普通的个人资料.
这种组合是构建服务器(例如TeamCity)的一种非常常见的场景.
我已经为创建 JFileChooser 的 Swing GUI 编写了单元测试。由于单元测试作为服务在构建服务器上运行,因此单元测试需要作为本地系统帐户运行。但是,当单元测试尝试创建新的 JFileChooser 时,它们会抛出 NullPointerException。
我已将问题简化为将以下主类作为本地系统帐户运行(不是真正的代码)
package com.example.mcgr;
import javax.swing.*;
import java.io.IOException;
public class FileChooserAsSystem {
public static void main(String[] args) throws IOException {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.showDialog(null, "Ok");
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
使用以下构建文件。
<project>
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile" depends="clean">
<mkdir dir="build/classes"/>
<javac srcdir="src" destdir="build/classes"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/FileChooserAsSystem.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="com.example.mcgr.FileChooserAsSystem"/>
</manifest>
</jar>
</target>
<target name="run">
<java …
Run Code Online (Sandbox Code Playgroud) 我有这个代码:
string certificateFilePath = @"C:\Users\Administrator\Documents\Certificate.pfx";
string certificateFilePassword = "Some Password Here";
X509Certificate clientCertificate = new X509Certificate(certificateFilePath, certificateFilePassword);
TcpClient client = new TcpClient(host, port);
SslStream stream = new SslStream(client.GetStream(), false, (sender, certificate, chain, errors) => true);
X509CertificateCollection clientCertificates = new X509CertificateCollection {clientCertificate};
stream.AuthenticateAsClient(host, clientCertificates, SslProtocols.Tls, false);
Run Code Online (Sandbox Code Playgroud)
当我在控制台应用程序中运行代码时,一切正常,stream.IsAuthenticated
并stream.IsMutuallyAuthenticated
返回true
并stream.LocalCertificate
包含正确的证书对象。
然而,当在 a 中运行完全相同的代码时Windows Service (as LOCAL SYSTEM user)
,虽然stream.IsAuthenticated
返回true
,stream.IsMutuallyAuthenticated
返回false
并stream.LocalCertificate
返回null
。
在这两种情况下都会发生这种情况,在第一行运行后clientCertificate
加载正确的认证数据并包含证书Subject …
我有一个作为本地系统运行的脚本,它执行一些操作,包括检查用户是否已登录,如果是,它会运行 PowerShell 代码片段来显示 toast 通知,如下所示。
如果 PS 以当前用户身份运行,则可以正常工作。如果它作为 LocalSystem 运行,则当前用户看不到 toast,因为输出发送到会话 0(对于本地系统帐户)。
如果作为本地系统运行并且不请求用户凭据,是否可以向登录用户显示 toast 通知?
Add-Type -AssemblyName System.Windows.Forms
$global:balloon = New-Object System.Windows.Forms.NotifyIcon
$path = (Get-Process -id $pid).Path
$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Info
$balloon.BalloonTipText = "$Text"
$balloon.BalloonTipTitle = "$Title"
$balloon.Visible = $true
$balloon.ShowBalloonTip($Miliseconds)
Run Code Online (Sandbox Code Playgroud) c# ×1
java ×1
jfilechooser ×1
nuget ×1
powershell ×1
selenium ×1
selenium-rc ×1
ssl ×1
sslstream ×1
swing ×1
teamcity ×1
toast ×1
unit-testing ×1
windows ×1
windows-7 ×1