小编Rog*_*_88的帖子

无法无头调用 Firefox

我想知道为什么会收到以下错误消息以及如何修复它:

回溯(最近一次调用):<\module> 中的文件“teste.py”,第 30 行

主要的()

文件“teste.py”,第 24 行,在主目录中

驱动程序 = connectFirefox(defineOptions())

文件“teste.py”,第 18 行,在 connectFirefox 中

驱动程序 = webdriver.Firefox(firefox_options=options)

文件“/usr/lib/python3.6/site-packages/selenium/webdriver/firefox /webdriver.py”,第 125 行,在init 中

如果 options.binary 不是 None:

AttributeError: 'Options' 对象没有属性 'binary'

我的代码:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.chrome.options import Options

def defineOptions():
    options = Options()
    options.add_argument("--headless")
    return options

def connectChrome(options):
    chromeDriverPath = "/usr/bin/chromedriver"
    driver = webdriver.Chrome(chromeDriverPath, chrome_options=options)
    print("Chrome Headless Browser Invoked")
    return driver

def connectFirefox(options):
    driver = webdriver.Firefox(firefox_options=options)
    print("Firefox Headless Browser Invoked")
    return …
Run Code Online (Sandbox Code Playgroud)

python headless-browser google-chrome-headless firefox-headless

6
推荐指数
1
解决办法
5755
查看次数

SELECT查询在C#方法中返回异常

我是 C# 和 Npgsql 的新手,我正在尝试在某个表中进行搜索,但出现异常。

public User Login(Account c)
{
    User usr = new User();
    using (NpgsqlConnection con = new NpgsqlConnection(strConnection))
    {
        try
        {
            con.Open();
            NpgsqlCommand command = new NpgsqlCommand();
            command.Connection = con;
            command.CommandText = "SELECT name FROM public.user WHERE c_id IN (SELECT id FROM public.account WHERE email=@Email AND password=@Password)";
            command.Parameters.AddWithValue("Email", c.Email);
            command.Parameters.AddWithValue("Password", c.Password);
            NpgsqlDataReader dr = command.ExecuteReader();

            if (dr.HasRows)
            {
                usr.Name = dr["name"].ToString();
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }
    }    
    return usr;
}
Run Code Online (Sandbox Code Playgroud)

咆哮异常:

System.InvalidOperationException: '没有可用的行' …

c# sql npgsql

1
推荐指数
1
解决办法
1505
查看次数

尝试使用const int std :: array时出错

当我尝试使用const int std :: array时为什么会出现以下错误?我必须在错误消息中将"<"替换为"<\"以正确显示它:

#include <array>
#include <iostream>

using namespace std;

int main() {
    array<const int, 4> vals;

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

test.cpp:在函数'int main()'中:

test.cpp:7:22:错误:使用已删除的函数'std :: array :: array()'

array <\ const int,4> vals; ^ ~~~

在test.cpp中包含的文件中:1:0:/usr/include/c++/7.3.0/array:94:12:注意:'std :: array <\ const int,4> :: array()'是隐式删除,因为默认定义不正确:struct array ^ ~~~~

/usr/include/c++/7.3.0/array:94:12:错误:'struct std :: array <\ const int,4>'中未初始化的const成员

/usr/include/c++/7.3.0/array:110:56:注意:'const int std :: array <\ const int,4> :: _ M_elems [4]'应初始化typename _AT_Type :: _ Type _M_elems; ^ ~~~~~~~

c++ arrays initialization constants c++11

0
推荐指数
1
解决办法
402
查看次数