如何解决错误:未指定DISPLAY环境变量
我在Ubuntu Server中设置了一个Selenium Grid,其中一个Hub,在Ubuntu Desktop中设置了一个Node。在Node计算机上安装了Geckodriver和Firefox。并使用以下python代码。
from selenium import webdriver
from selenium.webdriver.firefox.options import Options as FirefoxOptions
options = webdriver.FirefoxOptions()
driver = webdriver.Remote(
command_executor='http://192.168.56.7:4444/wd/hub',options=options
)
但是出现错误错误:在节点计算机上未指定DISPLAY环境变量。
添加后工作正常
options.add_argument('--headless')
不想在无头模式下运行它。
谢谢大家。
解决方法
请尝试设置环境变量DISPLAY
。
您的问题与Selenium Error: no display specified有点重复
,查看@ peter-quan提供的链接。如果您正在通过SSH运行节点连接,则会遇到此问题。
除此之外,我还添加了有助于解决该问题的命令。
struct ContentView: View {
@State private var showingCustomSheet = false
var body: some View {
ZStack {
Button(action: {
self.showingCustomSheet.toggle()
}) {
Text("Fire")
.font(.largeTitle)
.foregroundColor(Color.red)
}
CustomAlertSheet(showingCustomSheet: $showingCustomSheet)
}
}
}
struct CustomAlertSheet: View {
@Binding var showingCustomSheet: Bool
var body: some View {
VStack {
Spacer()
if showingCustomSheet {
Rectangle()
.fill(Color.red)
.frame(width: 256,height: 128)
.transition(.move(edge: .bottom))
}
}
.animation(.default,value: showingCustomSheet)
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。