我试图用Ruby on Rails运行Selenium的示例scirpt.我要用代理运行它.这是我的代码:
require 'rubygems'
require 'bundler/setup'
# require your gems as usual
require "selenium-webdriver"
Selenium::WebDriver::Firefox.path = "/home/marc/Documents/firefox/firefox"
profile = Selenium::WebDriver::Firefox::Profile.new
proxy = Selenium::WebDriver::Proxy.new(:http => nil)
profile.proxy = proxy
driver = Selenium::WebDriver.for :firefox, :profile => profile
driver.navigate.to "http://google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
driver.quit
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
/home/marc/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.0.0.beta3.1/lib/selenium/webdriver/common/service.rb:115:in `connect_until_stable': unable to connect to Mozilla geckodriver 127.0.0.1:4445 (Selenium::WebDriver::Error::WebDriverError)
Run Code Online (Sandbox Code Playgroud)
有人能帮我吗...?我几个小时都在努力,找不到问题......真的不知道该怎么办.
环境:
Ubuntu 16.04 LTS,Firefox 45.0,rbenv 2.3.1
其他问题:有人知道Selenium + Ruby on Rails的一些例子吗?我找不到真正的好东西......文档很差:(
我想我在理解OOP如何工作方面遇到了问题.我已经改变了它的工作代码,但它不是我认为的那种方式.下面的场景(不,我不是自己创建一个用户登录,它真的只是本地开发人员更好地理解OOP):
我有一个database.php文件:
class Database {
/* Properties */
private $conn;
private $dsn = 'mysql:dbname=test;host=127.0.0.1';
private $user = 'root';
private $password = '';
/* Creates database connection */
public function __construct() {
try {
$this->conn = new PDO($this->dsn, $this->user, $this->password);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "";
die();
}
return $this->conn;
}
}
Run Code Online (Sandbox Code Playgroud)
所以在这个类我正在创建一个数据库连接,我返回连接(对象?)
然后我有第二个类,着名的User类(实际上我不使用自动加载,但我知道它):
include "database.php";
class User {
/* Properties */
private $conn;
/* Get database access */
public function __construct() {
$this->conn = …Run Code Online (Sandbox Code Playgroud) 我正在尝试将SQL查询作为预准备语句运行 - 我尝试绑定一个NULL值.好吧,我已经在网上做了一些研究,是的,我已经在stackoverflow上找到了所有已知的主题.
我的代码到目前为止:
$stmt = $db->prepare("SELECT c.*, COUNT(d.servername) as servercount, d.controller FROM customers C JOIN customerdata d ON c.id = d.customer WHERE isVdi = :isVdi AND d.controller = :controller GROUP BY d.customer ORDER BY c.name ASC, c.environment ASC");
$stmt->bindValue(':isVdi', $isVdi);
$stmt->bindValue(':controller', null, PDO::PARAM_INT);
$stmt->execute();
return $stmt->fetchAll();
Run Code Online (Sandbox Code Playgroud)
但这不起作用.我得到一个空结果数组.当我更换controller = :controller用controller IS NULL它完美.
最后,我想将变量绑定到:控制器,但是现在我正在尝试直接将NULL写入其中,因为这甚至不起作用.
我在这里找到了这种方式: 如何使用PDO插入NULL值?
我也已尝试过PDO::PARAM_NULL所有这些东西 - 没有任何作用.我真的不明白.
感谢任何帮助.
反应和所有这些东西都很新,所以我需要一些帮助。我最近在我的项目中添加了https://github.com/gajus/babel-plugin-react-css-modules插件。经过一些麻烦,我让它工作了,所以我现在可以在我的组件中使用我的本地 css 文件。到现在为止还挺好。
不是我想为整个应用程序添加引导程序。在我添加 css-modules 插件之前它工作了......
这是我的代码的相关部分(我猜......如果我错过了什么让我知道):
index.js(我的应用程序的入口点):
import 'bootstrap/dist/css/bootstrap.min.css';
...
Run Code Online (Sandbox Code Playgroud)
.babelrc:
{
"presets": [
"react"
],
"plugins": [
["react-css-modules", {
"exclude": "node_modules"
}]
]
}
Run Code Online (Sandbox Code Playgroud)
webpack.config.js :
/* webpack.config.js */
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
devtool: 'eval',
entry: [
path.resolve('src/index.js'),
],
output: {
path: path.resolve('build'),
filename: 'static/js/bundle.js',
publicPath: '/',
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
include: path.resolve('src'),
loader: 'babel-loader',
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader', …Run Code Online (Sandbox Code Playgroud) reactjs css-modules bootstrap-4 babel-plugin-react-css-modules
我有一个问题,不知何故我无法解决它。我尝试了几个小时,但我只是找不到解决方案。它适用于较旧的项目,但不适用于使用 create-react-app 创建的全新 React 项目。
考虑以下代码:
应用程序.js:
function App() {
const test = {
test1: {},
test2: {}
};
return (
<div className="App">
Cool!
<Test
name1="cool1"
{...test}
/>
</div>
);
}
export default App;
Run Code Online (Sandbox Code Playgroud)
这里没什么大不了的。如果我用 npm start 启动项目,一切都按预期进行,我会看到“酷!” 在浏览器中。(测试定义如下,它是一个返回 div 的简单组件。)
现在,如果我尝试...props在我的测试函数中使用参数,如下所示:
export const Test = ({name1, ...props}) => {
return (
<div>yay! {props.name1}</div>
)
};
Run Code Online (Sandbox Code Playgroud)
它在 chrome 中运行良好,但 Microsoft Edge 说:
SCRIPT1028:SCRIPT1028:需要的标识符、字符串或数字
我在旧项目中使用这种语法,用旧版本的 create-react-app 创建,没有任何问题,所以我不太确定问题出在哪里。这甚至可能是 create-react-app 中的一个普遍错误,因为该项目实际上是用它创建的,并且没有添加任何库。
最好的问候并感谢您的帮助!
我实际上是脚本,我脚本的一部分是FTP文件下载.代码字没有任何问题,但我不明白一个具体的部分.它是我自己没有编写的代码中唯一的部分.我理解代码是如何工作的,但实际上我并不理解函数如何返回它的值.你可能会对我的意思感到困惑,所以让我用一些代码解释一下:
function get-ftp {
try {
$ftprequest = [system.net.ftpwebrequest]::Create($uri)
$ftprequest.Credentials = New-Object system.net.networkcredential($user,$pass)
$ftprequest.Proxy = $null
$ftprequest.Method = [System.Net.WebRequestMethods+FTP]::ListDirectory
$ftpresponse = $ftprequest.GetResponse()
$reader = New-Object IO.StreamReader $ftpresponse.GetResponseStream()
$reader.ReadToEnd()
$reader.Close()
$ftpresponse.Close()
}
catch {
Write-host "Error while reading filenames"
}
}
Run Code Online (Sandbox Code Playgroud)
所以这是我从FTP服务器获取所有目录的功能.我用这段代码调用这个函数:
$allXmlFiles = get-ftp
Run Code Online (Sandbox Code Playgroud)
因此,在调用之后,我$allXmlFiles包含一个字符串(使用getTypeon 测试$allXmlFiles),其中包含服务器上的所有文件名.现在我的问题:FTP的答案是如何传递给这个变量的?return功能中没有,所以我很困惑这是如何工作的.我试过这样就把try/catch功能拿出来直接获得答案,但那不起作用.我试图找到它$reader,并在$ftpresponse-没有成功.
如果有人能解释我在这里发生的事情,那真的很酷.如上所述,代码有效,但我想了解这里发生了什么.
pdo ×2
php ×2
reactjs ×2
babel-plugin-react-css-modules ×1
bootstrap-4 ×1
css-modules ×1
function ×1
geckodriver ×1
javascript ×1
mysql ×1
oop ×1
powershell ×1
selenium ×1