错误:未指定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)
    }
}