- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FindElementsUsingJS {
static WebDriver driver= new FirefoxDriver();
public static void main(String[] args) {
driver.get("http://scripting.jdpoweronline.com/mrIWeb/mrIWeb.dll?I.Project=T1_QTYPE&i.test=1");
// get HTML of above URL
String scriptContents = "return '<html>'+$( 'html' ).html()+'</html>'";
String contentss = (String) ((JavascriptExecutor) driver).executeScript(scriptContents);
// get DOM obj
String content="return $.parseHTML('"+contentss+"')";
System.out.println(((JavascriptExecutor) driver).executeScript(content));
//System.out.println(contentss);
}
}
嗨,我想做以下事情1.使用JavascriptExecutor获取contents var中的HTML文档(工作正常)2. 创建收集的 HTML 的 DOM 对象(不起作用异常(exception))。3. 使用预定义的方法获取 DOM 元素。
我遇到以下异常
> Exception in thread "main" org.openqa.selenium.WebDriverException: unterminated string literal
Command duration or timeout: 14 milliseconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'ATMECSINDT-068', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.8.0-37-generic', java.version: '1.7.0_55'
Session ID: c3857c80-97e6-4955-9323-d1418b237441
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, browserConnectionEnabled=true, webStorageEnabled=true, nativeEvents=false, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=30.0}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:504)
at publicc.FindElementsUsingJS.main(FindElementsUsingJS.java:27)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: unterminated string literal
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: 'ATMECSINDT-068', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.8.0-37-generic', java.version: '1.7.0_55'
Driver info: driver.version: unknown
at <anonymous class>.handleEvaluateEvent(http://scripting.jdpoweronline.com/
最佳答案
您为 scriptContents
提供的字符串文字在我看来是错误的。 '
位于 +
之前,而不是 +
之后。
这是正确的:
String scriptContents = "'<html>'+$( 'html' ).html()+'<html>'";
希望有帮助。
关于javascript - 线程 "main"org.openqa.selenium.WebDriverException : unterminated string literal 中出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25079449/
这是我在试验 JS 时的最新发现: (function() { return this; }).call('string literal'); // => [String: 'string liter
在 C 中有没有一种方法可以使用宏从字 rune 字创建字符串文字? 比如我有 'a' 我想创建字符串文字 "a" 澄清问题: #define A 'a' write(fd, "x=" CHAR2ST
令我困扰的是为什么术语“literal”被用来指代NSString和NSArray等类的实例。我只看到了用于引用 NSString 的术语,并且天真地认为它与“字面上”是一个字符串(位于引号之间)有关
我有以下使用 smarty 模板引擎的代码 在 php 文件中: $smarty->assign('SITE_URL', 'http://localhost/mis/'); 在 tpl 文件中:
我正在使用 regex101 tool 制作正则表达式并在解释字段中阅读 [.] - 文字字符 .[\.] - 匹配字符 .字面上地 我在“字面字符”和“字面字符”之间迷失了方向。 这两者有什么区别?
这个问题在这里已经有了答案: Single quotes vs. double quotes in C or C++ (15 个答案) 关闭 4 年前。 我正在阅读一本讨论“字 rune 字”与“字
浮点文字 float x = 3.2f; 的直接赋值和隐式转换为 float 的 double 之间的位表示是否存在差异 float x2 = 3.2;? 即是 #define EQUAL(FLOAT
这个极其简单的 Rust 程序: fn main() { let c = "hello"; println!(c); } 抛出以下编译时错误: error: expected a li
这个极其简单的 Rust 程序: fn main() { let c = "hello"; println!(c); } 抛出以下编译时错误: error: expected a li
是否有单行,类型 mapfilter ... es5+ higherfunction 或 ...?希望解决方案描述如何以及为什么和引用。如果有人知道为什么曾经不起作用。 timeTableKeys:是
我有包含这些声明的代码: class IRealNetDll; extern "C"__declspec(dllexport) IRealNetDll * CreateRealInstance(int
我有一个用于我们的一些服务的 SOAP 服务器 API,其中一位客户说他们不会与不提供至少 WS-I 基本配置文件合规性绑定(bind)的服务集成。 那么,问题是任何版本的 Delphi 都支持 Do
我已经尝试使用这两个循环以及列表理解。即使我正在尝试将数字转换为列表中的整型,两者都无法解析整数。
在代码中隐藏文字值的主要现有方法是什么,以便仅使用 hexdumper 或反编译器不容易跟踪它们? 例如,而不是编码: static final int MY_VALUE = 100; 我们可
我正在尝试使用文字来匹配 Empty Guid,但我不知道这里发生了什么: let [] EmptyGuid = System.Guid () let someFunction () = System
我正在尝试搜索 [Panels] like "*,*" 在工作表中,不幸的是,它没有准确检索该字符串,而是检索如下内容: [Panels] like "*blah,*" [Panels] like "
我看不出自然语言编程和文学编程之间的区别。如果有人解释,我将不胜感激。 最佳答案 Natural language programming是一种以近似于人类书写或说话的语言的形式向计算机表达指令的
我想从字符串数组中初始化一个 pydantic 文字 from typing import Literal from pydantic import BaseModel CLASS_NAME_VALU
我正在尝试在代码后面编写我的js代码。我定义了一个名为“contentPie”的文字,然后将 javascript 代码放入其文本中。但这不起作用。 contentPie.Text = "window
我有一个简单的数据集,可以使用如下行进行解析: R1 (a/30) to R2 (b/30), metric 30 我需要从上面得到的唯一数据如下: R1, a, 30, R2, 192.168.0.
我是一名优秀的程序员,十分优秀!