0
我有這樣的代碼:nknown錯誤:Runtime.evaluate拋出異常:語法錯誤:意外的令牌VAR
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
// javascriptExecutor.executeScript("W.setOffer({offer: {kind: \"coupon\", title: \"Hello\", availability: " +
// "\"available\"}},{})");
String script =
"var aLocation = {}" +
"var aOffer = {}" +
"var aAdData = " +
"{ " +
"location: aLocation, " +
"offer: aOffer " +
" } " +
"var aClientEnv = " +
" { " +
" sessionid: 「」, " +
" cookie: 「」, " +
" 「rtserver-id」: 1, " +
" lon: 34.847, " +
" lat: 32.123, " +
" venue: 「」, " +
" venue_context: 「」, " +
// AD-{"campaignId":8224,"offerId":4172}
// see Venue Context for more information.
" source: 「」," + // One of the following (string) values: ADS_PIN_INFO,
// ADS_0SPEED_INFO, ADS_LINE_SEARCH_INFO,
// ADS_ARROW_NEARBY_INFO, ADS_CATEGORY_AUTOCOMPLETE_INFO,
// ADS_HISTORY_LIST_INFO
// (this field is also called 「channel」)
" locale: 「」" + // ISO639-1 language code (2-5 characters), supported formats:
// * en/he/fr/…
// * en-GB/pt-BR/en_GB/pt_BR
// * es-419/es_419
" } " +
"W.setOffer(aAdData, aClientEnv);";
javascriptExecutor.executeScript(script);
}
,但它的executeScript
org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected token var
(Session info: chrome=42.0.2298.0)
(Driver info: chromedriver=2.9.248307,platform=Mac OS X 10.9.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 18 milliseconds
失敗這裏是腳本。我錯過了什麼嗎?
我不能使用var
來保存元素嗎?
var aLocation = {}
var aOffer = {}
var aAdData = {
location: aLocation,
offer: aOffer
}
var aClientEnv = {
sessionid: 「」,
cookie: 「」,
「rtserver - id」: 1,
lon: 34.847,
lat: 32.123,
venue: 「」,
venue_context: 「」,
source: 「」,
locale: 「」
}
W.setOffer(aAdData, aClientEnv);
而且我也必須替換'「和」==>「' – 2015-02-11 12:10:15