我正在使用Firefox 47.0和Selenium 2.53.最近他们一直是Selenium和Firefox之间的一个错误,它使代码无效.其中一个解决方案是使用Marionnette驱动程序.
我按照本网站的说明使用这个新驱动程序与RemotWebDriver,但我一直有错误:
WARN - 异常:线程"main"中的异常org.openqa.selenium.WebDriverException:驱动程序可执行文件的路径必须由webdriver.gecko.driver系统属性设置; 有关更多信息,请参阅https://github.com/jgraham/wires.最新版本可以从....下载
我到目前为止尝试的代码非常简单:
public class Test {
static WebDriver driver;
static Wait<WebDriver> wait;
public static void main(String[] args) throws MalformedURLException {
System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setCapability("marionette", true);
cap.setBrowserName("firefox");
driver = new RemoteWebDriver(new URL("http://192.168.117.135:5555/wd/hub"), cap);//true to enable the JS
wait = new WebDriverWait(driver, 3000);
final String url = "https://www.google.com/";
JavascriptExecutor js = (JavascriptExecutor) driver;
try {
driver.navigate().to(url);
} finally {
driver.close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我确定geckodriver.exe的路径是正确的,我不知道我在哪里做错了.
编辑1:我尝试了以下代码:
public class Test …Run Code Online (Sandbox Code Playgroud) 我想根据不同条件的结果添加一个元素。现在,我是这样做的:
val add1 = if(condition1) Seq(ENUM_ELEMENT_1) else Seq()
val add2 = if(condition2) Seq(ENUM_ELEMENT_2) else Seq()
return Seq(add1, add2).flatten
Run Code Online (Sandbox Code Playgroud)
如果我使用Java,则只需在开头创建一个空的ArrayList(),然后在代码遇到ifs时将其添加到此列表中。但是在Scala中,我将不得不使用Seq的可变对象,并且我不知道这里是否合适。
我不明白模式匹配的一个方面。
在模式匹配的文档中,他们显示了一个示例,例如:
https://docs.scala-lang.org/tour/pattern-matching.html
abstract class Notification
case class Email(sender: String, title: String, body: String) extends Notification
case class SMS(caller: String, message: String) extends Notification
case class VoiceRecording(contactName: String, link: String) extends Notification
def showNotification(notification: Notification): String = {
notification match {
case Email(sender, title, _) =>
s"You got an email from $sender with title: $title"
case SMS(number, message) =>
s"You got an SMS from $number! Message: $message"
case VoiceRecording(name, link) =>
s"You received a Voice Recording from $name! Click the …Run Code Online (Sandbox Code Playgroud) 我按如下方式创建 Airflow DAG:
dag = DAG(...)
Run Code Online (Sandbox Code Playgroud)
但在多个教程和课程中,我看到他们使用with ... as这样的子句:
with DAG(...) as dag:
# Code that will use the dag variable.
Run Code Online (Sandbox Code Playgroud)
我想这样,DAG实例将在调度程序执行代码块后被销毁,但是这样做有真正的好处吗?我找不到任何讨论此问题的文档。
我想使用hbase hortonworks连接器。 github 指南
但是我不知道如何在我的项目中导入它。我有以下build.sbt:
name := "project"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.apache.spark" % "spark-core_2.11" % "2.2.0",
"org.apache.spark" % "spark-sql_2.11" % "2.2.0",
"org.scala-lang" % "scala-compiler" % "2.11.8",
"com.hortonworks" % "shc" % "1.1.2-2.1-s_2.11-SNAPSHOT"
)
Run Code Online (Sandbox Code Playgroud)
它给了我以下未解决的依赖关系:
错误:导入SBT项目时出错:
...
[警告] ====本地:尝试过[警告] ivy.xml [警告] ====公共:尝试过[警告]
https://repo1.maven.org/ maven2 / com / hortonworks / shc / 1.1.2-2.1-s_2.11-SNAPSHOT / shc-1.1.2-2.1-s_2.11-SNAPSHOT.pom [info]解决jline#jline; 2.12.1 ... [警告] ::::::::::::::::::::::::::::::::::::::::::::::::: [警告] ::
UNRESOLVED DEPENDENCIES :: [警告] ::::::::::::::::::::::::::::::::::::::::::::: ::: [警告] :: com.hortonworks#shc; 1.1.2-2.1-s_2.11-SNAPSHOT:找不到[警告] :::::::::::::::::: :::::::::::::::::::::::::: [警告] [警告]注意:未解决的依赖项路径:[警告] com.hortonworks:shc:1.1。 …
我有以下一种控制器方法:
def edit(bookId: Int): Action[AnyContent] = messagesAction {implicit request => {
val books = Book.getBookId(bookId)
if(books.nonEmpty) Ok(views.html.book.create(bookForm.fill(books.head)))
else NotFound("Book is not found.")
}}
Run Code Online (Sandbox Code Playgroud)
但是我对自己的工作方式不满意。
实际上,我不想测试列表(书籍val)是否为空。
我尝试了类似的东西:
def edit2(bookId: Int): Action[AnyContent] = messagesAction {implicit request => {
Book.getBookId(bookId).foreach(book => Ok(views.html.book.create(bookForm.fill(book))))
NotFound("Book is not found.")
}}
Run Code Online (Sandbox Code Playgroud)
它确实可以编译,但是我每次都有NOtFound重定向。
我该怎么办?
我有2个RDD [Int]源和noSourcesVertex。我想计算一个将创建2个新RDD的地图。
val sourcesFormatted = sources.map(x => (Some(x), (Some(x), Some(x))))
val noSourcesVertexFormatted = noSourcesVertex.map(x => (Some(x), (Some(x), None)))
val outInit = sourcesFormatted.union(noSourcesVertexFormatted)
Run Code Online (Sandbox Code Playgroud)
但是当我执行先例代码时,出现错误:
错误:类型不匹配;找到:org.apache.spark.rdd.RDD [(Some [Int],(Some [Int],None.type))]]必需:org.apache.spark.rdd.RDD [(Some [Int],(Some [Int],Some [Int]))] val outInit = sourcesFormatted.union(noSourcesVertexFormatted)
我认为发生此错误是因为我试图加入其第三列具有不同类型的2个RDD。
由于我对Option的机制的理解,我没想到这种行为,Some(something)和None具有相同的类型-> Option。
为什么我会出现此错误?
当我在python中创建具有气流的DAG时,我可以传递一些参数。
SETTINGS = {
'owner': 'hello',
'depends_on_past': False,
'start_date': datetime(2019, 1, 1),
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
}
dag = DAG(dag_id,
schedule_interval='@daily',
catchup=False,
default_args=SETTINGS)
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做时,我仍然必须打开界面并单击一下以启用DAG。我想知道是否有设置可以直接在创建时通过。我认为这与“暂停”有关,但找不到参数的名称。
我有这个简单的代码:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Google Map API on xhtml</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
<head>
<body>
<script>
//Initialise la map
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
scrollwheel: true,
mapTypeControl: false,
center: {lat: 48.8534100, lng: 2.3488000},
zoom: 13,
streetViewControl: false,
zoomControl:true
});
}
function drawOnclick() {
alert("clicked");
var antennasCircle = new google.maps.Circle({
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: …Run Code Online (Sandbox Code Playgroud) 我正在使用mysql数据库。我想用我写的脚本连接到它:
<?php
function getDatabase() {
$host = 'localhost:3306';
$db = 'freya';
$login = 'root';
$pw = 'helloitsme';
try {
return new PDO('mysql:host='.$host.';dbname='.$db.';charset=utf8', $login, $pw);
} catch (Exception $e) {
die('Erreur : '.$e->getMessage());
}
}
$db = getDatabase();
Run Code Online (Sandbox Code Playgroud)
我已经看到此错误是经常发生的,但是没有解决方案。我检查了my.cnf,并确定我使用的是mysql数据库所在的端口。我还确定数据库名称,登录名和密码正确,因为我正在使用它们通过外壳访问数据库。
可能是什么问题呢 ?
我已经制作了这段代码:
case class RawPanda(id: Long, zip: String, pt: String, happy: Boolean, attributes: Array[Double])
case class PandaPlace(name: String, pandas: Array[RawPanda])
object TestSparkDataFrame extends App{
System.setProperty("hadoop.home.dir", "E:\\Programmation\\Libraries\\hadoop")
val conf = new SparkConf().setAppName("TestSparkDataFrame").set("spark.driver.memory","4g").setMaster("local[*]")
val session = SparkSession.builder().config(conf).getOrCreate()
import session.implicits._
def createAndPrintSchemaRawPanda(session:SparkSession):DataFrame = {
val newPanda = RawPanda(1,"M1B 5K7", "giant", true, Array(0.1, 0.1))
val pandaPlace = PandaPlace("torronto", Array(newPanda))
val df =session.createDataFrame(Seq(pandaPlace))
df
}
val df2 = createAndPrintSchemaRawPanda(session)
df2.show
+--------+--------------------+
| name| pandas|
+--------+--------------------+
|torronto|[[1,M1B 5K7,giant...|
+--------+--------------------+
val pandaInfo = df2.explode(df2("pandas")) {
case Row(pandas: Seq[Row]) …Run Code Online (Sandbox Code Playgroud) 我需要将a转换std::string为a const char*.
为此,我c_str()在字符串上使用了该方法,如下面的代码所示:
#include <iostream>
#include <string>
using namespace std;
int main(void) {
string testStr;
cin >> testStr;
const char* testStrConst = testStr.c_str();
cout << testStrConst << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果我输入"Hey hello"终端,当此代码运行时,输出只是"Hey".
为什么第二个词被忽略了?
scala ×5
airflow ×2
apache-spark ×2
java ×2
c++ ×1
firefox ×1
geckodriver ×1
google-maps ×1
hbase ×1
html ×1
javascript ×1
mysql ×1
php ×1
python ×1
rdd ×1
sbt ×1
selenium ×1
string ×1