How does one get the dbt power user extension in vscode to actually work? I have one and clicked to update it but got an error - dbt

I got two errors. The first is :
Error while updating 'dbt Power User' extension. Please check the [log](command:workbench.action.showWindowLog) for more details.
The second error is:
[2022-09-27 09:21:53.593] [renderer4] [error] [Extension Host] (node:16272) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `Code --trace-warnings ...` to show where the warning was created)
[2022-09-27 09:21:55.813] [renderer4] [error] XHR failed: Download: XHR failed
at G.downloadExtension (vscode-file://vscode-app/c:/Users/josh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:83:170479)
at async G.doRun (vscode-file://vscode-app/c:/Users/josh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:83:169610)
[2022-09-27 09:22:05.897] [renderer4] [error] ["Download: XHR failed"," at G.downloadExtension (vscode-file://vscode-app/c:/Users/josh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:83:170479)"," at async G.doRun (vscode-file://vscode-app/c:/Users/josh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:83:169610)"]
[2022-09-27 09:22:05.916] [renderer4] [error] XHR failed: Download: XHR failed
at G.downloadExtension (vscode-file://vscode-app/c:/Users/josh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:83:170479)
at async G.doRun (vscode-file://vscode-app/c:/Users/josh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:83:169610)
[2022-09-27 09:30:55.976] [renderer4] [error] ["Download: XHR failed"," at G.downloadExtension (vscode-file://vscode-app/c:/Users/josh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:83:170479)"," at async G.doRun (vscode-file://vscode-app/c:/Users/josh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:83:169610)"]
[2022-09-27 09:30:56.023] [renderer4] [error] XHR failed: Download: XHR failed
at G.downloadExtension (vscode-file://vscode-app/c:/Users/josh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:83:170479)
at async G.doRun (vscode-file://vscode-app/c:/Users/josh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:83:169610)

Related

CoreUi - why nightwatch cannot run e2e tests?

I want to start working with CoreUi Admin template and create project containing unit and e2e testing.
In the begining, I install CoreUi like shown in documentation:
git clone https://github.com/coreui/coreui-free-vue-admin-template.git CoreUI-Vue
cd CoreUI-Vue
npm install
Everything is ok. Now I want to run whole unit and e2e tests:
npm run test:unit
npm run test:e2e
All unit tests run properly. But when I run e2e test I got the following errors:
> #coreui/coreui-free-vue-admin-template#3.1.4 test:e2e
> vue-cli-service test:e2e
INFO Starting development server...
[BABEL] Note: The code generator has deoptimised the styling of /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#coreui/vue/dist/coreui-vue.common.js as it exceeds the max of 500KB.
WARNING Compiled with 2 warnings 2:47:38 PM
warning
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
css/app.10fee0d6.css (383 KiB) js/chunk-28d6db65.e7636129.js (488 KiB)
js/chunk-2d0a400c.650c6f3a.js (3.37 MiB) js/chunk-2d0ae5e6.22010046.js (390 KiB)
js/chunk-2d237b34.468fc7b7.js (1.36 MiB)
js/chunk-vendors.03b8fe62.js (687 KiB)
warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (1.07 MiB)
js/chunk-vendors.03b8fe62.js
css/app.10fee0d6.css
js/app.94002fbe.js
App running at:
- Local: http://localhost:8080/
- Network: http://172.31.33.121:8080/
App is served in production mode.
Note this is for preview or E2E testing only.
INFO Running end-to-end tests ...
[Test] Test Suite
=================
⚠ Error connecting to localhost on port 9515.
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (348ms)
✖ test
An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally." at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
SKIPPED:
- CoreUI Vue e2e tests
ERROR Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
at makeError (/home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:174:9)
at /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:278:16
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
bagsiur#DESKTOP-718MBR1:~/Projects/B2B/test-coreui/CoreUI-Vue$
bagsiur#DESKTOP-718MBR1:~/Projects/B2B/test-coreui/CoreUI-Vue$ npm run test:e2e
> #coreui/coreui-free-vue-admin-template#3.1.4 test:e2e
> vue-cli-service test:e2e
INFO Starting development server...
WARNING Compiled with 2 warnings 3:06:39 PM
warning
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
css/app.10fee0d6.css (383 KiB)
js/chunk-28d6db65.e7636129.js (488 KiB)
js/chunk-2d0a400c.650c6f3a.js (3.37 MiB)
js/chunk-2d0ae5e6.22010046.js (390 KiB)
js/chunk-2d237b34.468fc7b7.js (1.36 MiB)
js/chunk-vendors.03b8fe62.js (687 KiB)
warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (1.07 MiB)
js/chunk-vendors.03b8fe62.js
css/app.10fee0d6.css
js/app.94002fbe.js
App running at:
- Local: http://localhost:8080/
- Network: http://172.31.33.121:8080/
App is served in production mode.
Note this is for preview or E2E testing only.
INFO Running end-to-end tests ...
[Test] Test Suite
=================
⚠ Error connecting to localhost on port 9515.
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (348ms)
✖ test
An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally." at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
SKIPPED:
- CoreUI Vue e2e tests
ERROR Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
at makeError (/home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:174:9)
at /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I work on wsl2 and Debian. My node.js version is v13.14.0 and npm is 7.12.1. I installed chromedriver in version: ChromeDriver 2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706) and last stable google chrome: google-chrome-stable 90.0.4430.212-1
What do I miss? Where could be the cause of the error in running e2e tests?
#UPDATE: I put the configuration of Nightwatch.conf.json:
// http://nightwatchjs.org/gettingstarted#settings-file
const path = require('path')
const deepmerge = require('deepmerge')
const chromedriver = require('chromedriver')
// user may have not installed geckodriver
let geckodriver = {}
try {
geckodriver = require('geckodriver')
} catch (e) {}
const userOptions = JSON.parse(process.env.VUE_NIGHTWATCH_USER_OPTIONS || '{}')
const useSelenium = process.env.VUE_NIGHTWATCH_USE_SELENIUM === '1'
const startHeadless = process.env.VUE_NIGHTWATCH_HEADLESS === '1'
const concurrentMode = process.env.VUE_NIGHTWATCH_CONCURRENT === '1'
const chromeArgs = []
const geckoArgs = []
if (startHeadless) {
chromeArgs.push('headless')
geckoArgs.push('--headless')
}
const defaultSettings = {
src_folders: ['tests/e2e/specs'],
output_folder: 'tests/e2e/reports',
page_objects_path: 'tests/e2e/page-objects',
custom_assertions_path: 'tests/e2e/custom-assertions',
custom_commands_path: 'tests/e2e/custom-commands',
globals_path: path.resolve('tests/e2e/globals.js'),
test_workers: concurrentMode,
test_settings: {
default: {
detailed_output: !concurrentMode,
launch_url: '${VUE_DEV_SERVER_URL}'
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
chromeOptions: {
w3c: false,
args: chromeArgs
}
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
alwaysMatch: {
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: geckoArgs
}
}
},
webdriver: useSelenium ? {} : {
server_path: geckodriver.path,
port: 4444
}
}
}
}
const baseSettings = deepmerge(defaultSettings, webdriverServerSettings())
module.exports = deepmerge(baseSettings, adaptUserSettings(userOptions))
function adaptUserSettings (settings) {
// The path to nightwatch external globals file needs to be made absolute
// if it is supplied in an additional config file, due to merging of config files
if (settings.globals_path) {
settings.globals_path = path.resolve(settings.globals_path)
}
return settings
}
function webdriverServerSettings () {
if (useSelenium) {
return {
selenium: {
start_process: true,
host: '127.0.0.1',
port: 4444,
server_path: require('selenium-server').path,
cli_args: {
'webdriver.chrome.driver': chromedriver.path,
'webdriver.gecko.driver': geckodriver.path
}
}
}
}
return {
webdriver: {
start_process: true,
port: 9515,
server_path: chromedriver.path
}
}
}
Version mismatch of chromedriver and chrome is the most common reason of e2e failing like this.
ChromeDriver 2.41 supports Chrome v67-69
your google-chrome-stable 90.0.4430 needs ChromeDriver 90.0.4430

Webdriverio Cucumberjs tests for a React Native app fails on AWS Device Farm - Socket hang up

I'm writing End-to-ends tests for a React Native app using WebdriverIo, Appium and Cucumberjs and deploying the tests on the AWS Device Farm.
The tests are working fine both on the Android simulator and on an actual real device. Though, on AWS, it throws errors such as (node:3113) DeprecationWarning: Got: "options.rejectUnauthorized" is now deprecated, please use "options.https.rejectUnauthorized" and RequestError: socket hang up. This is shown in more detail below:
[DeviceFarm] echo "Start Appium Node test"
Start Appium Node test
[DeviceFarm] npm run only-one-test-aws
> e2e-cucumber-wdio-appium#1.0.0 only-one-test-aws /tmp/scratch0EgKio.scratch/test-packageFvDXet
> npx wdio ./wdio.android.conf.js --spec ./features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
Execution of 1 spec files started at 2020-06-04T18:23:19.220Z
2020-06-04T18:23:19.223Z INFO #wdio/cli:launcher: Run onPrepare hook
2020-06-04T18:23:19.254Z INFO #wdio/cli:launcher: Run onWorkerStart hook
2020-06-04T18:23:19.256Z INFO #wdio/local-runner: Start worker 0-0 with arg: ./wdio.android.conf.js,--spec,./features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
[0-0] 2020-06-04T18:23:20.961Z INFO #wdio/local-runner: Run worker command: run
[0-0] 2020-06-04T18:23:21.062Z DEBUG #wdio/local-runner:utils: init remote session
[0-0] 2020-06-04T18:23:21.095Z INFO webdriverio: Initiate new session using the ./protocol-stub protocol
[0-0] RUNNING in undefined - /features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
[0-0] 2020-06-04T18:23:22.697Z DEBUG #wdio/local-runner:utils: init remote session
[0-0] 2020-06-04T18:23:22.714Z INFO webdriverio: Initiate new session using the webdriver protocol
[0-0] 2020-06-04T18:23:22.717Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session
[0-0] 2020-06-04T18:23:22.717Z INFO webdriver: DATA {
capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
desiredCapabilities: {}
}
[0-0] (node:3113) DeprecationWarning: Got: "options.rejectUnauthorized" is now deprecated, please use "options.https.rejectUnauthorized"
[0-0] 2020-06-04T18:24:52.853Z WARN webdriver: Request timed out! Consider increasing the "connectionRetryTimeout" option.
[0-0] 2020-06-04T18:24:52.856Z INFO webdriver: Retrying 1/3
[0-0] 2020-06-04T18:24:52.857Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session
[0-0] 2020-06-04T18:24:52.857Z INFO webdriver: DATA {
capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
desiredCapabilities: {}
}
[0-0] 2020-06-04T18:24:54.004Z DEBUG webdriver: request failed due to response error: unknown error
[0-0] 2020-06-04T18:24:54.004Z WARN webdriver: Request failed with status 500 due to An unknown server-side error occurred while processing the command. Original error: end of central directory record signature not found
[0-0] 2020-06-04T18:24:54.005Z INFO webdriver: Retrying 2/3
[0-0] 2020-06-04T18:24:54.014Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session
[0-0] 2020-06-04T18:24:54.014Z INFO webdriver: DATA {
capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
desiredCapabilities: {}
}
[0-0] 2020-06-04T18:24:54.030Z ERROR webdriver: RequestError: socket hang up
at ClientRequest.<anonymous> (/tmp/scratch0EgKio.scratch/test-packageFvDXet/node_modules/got/dist/source/core/index.js:817:25)
at Object.onceWrapper (events.js:417:26)
at ClientRequest.emit (events.js:322:22)
at ClientRequest.EventEmitter.emit (domain.js:482:12)
at ClientRequest.origin.emit (/tmp/scratch0EgKio.scratch/test-packageFvDXet/node_modules/#szmarczak/http-timer/dist/source/index.js:39:20)
at Socket.socketOnEnd (_http_client.js:453:9)
at Socket.emit (events.js:322:22)
at Socket.EventEmitter.emit (domain.js:482:12)
at endReadableNT (_stream_readable.js:1187:12)
at connResetException (internal/errors.js:608:14)
at Socket.socketOnEnd (_http_client.js:453:23)
at Socket.emit (events.js:322:22)
at Socket.EventEmitter.emit (domain.js:482:12)
at endReadableNT (_stream_readable.js:1187:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
[0-0] 2020-06-04T18:24:54.031Z ERROR #wdio/runner: Error: Failed to create session.
socket hang up
at startWebDriverSession (/tmp/scratch0EgKio.scratch/test-packageFvDXet/node_modules/webdriver/build/utils.js:45:11)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
[0-0] Error: Failed to create session.
socket hang up
2020-06-04T18:24:54.147Z DEBUG #wdio/local-runner: Runner 0-0 finished with exit code 1
[0-0] FAILED in undefined - /features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
2020-06-04T18:24:54.148Z INFO #wdio/cli:launcher: Run onComplete hook
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:01:34
2020-06-04T18:24:54.164Z INFO #wdio/local-runner: Shutting down spawned worker
2020-06-04T18:24:54.416Z INFO #wdio/local-runner: Waiting for 0 to shut down gracefully
2020-06-04T18:24:54.417Z INFO #wdio/local-runner: shutting down
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! e2e-cucumber-wdio-appium#1.0.0 only-one-test-aws: `npx wdio ./wdio.android.conf.js --spec ./features/recarga/verificacacaoCodigoDeAcessoInvalido.feature`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the e2e-cucumber-wdio-appium#1.0.0 only-one-test-aws script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/device-farm/.npm/_logs/2020-06-04T18_24_54_506Z-debug.log
[DEVICEFARM] ########### Entering phase post_test ###########
[DEVICEFARM] ########### Finish executing testspec ###########
[DEVICEFARM] ########### Setting upload permissions ###########
[DEVICEFARM] Tearing down your device. Your tests report will come shortly.
I also tried this question's solution by installing the webdriverio and #wdio/cli dependencies globally, though it did not work to me.
PS: I've already been able to successfully perform tests on the AWS Device Farm using webdriverio and cucumber. Though, these errors started to show up for me recently and I still have no clue on how to solve them.
Can someone please help me with this?

ReferenceError: ReadableStream is not defined while running jest tests

My web app reads local files using a custom ReadableStream (in-order that I won't need to have a max file size that the platform supports) and it works great, both for correctly formatted files and error files. My app is built using React-Redux-Saga.
I'm now attempting to add limited e2e tests to my code to test the state management. I'm testing that when sending redux actions the state updates correctly. I'm testing the saga's using the package redux-saga-tester.
While running the jest client tests that read local files using the ReadableStream I built, I got an error ReferenceError: ReadableStream is not defined. What I understood is that the jsdom environment that jest uses is missing the ReadableStream implementation. I than added the web-streams-polyfill package to polyfill the ReadableStream class.
Now the validate file test is passing as in the browser:
test('Select and validate log file', async () => {
const testFile = testFileBuilder.valid();
storeTester.dispatch(fileSelected(testFile));
await storeTester.waitFor(FILE_VALIDATED);
const state = storeTester.getState().file;
expect(state.fileValidated).toBeTruthy();
});
My problem is that when I run a second validation test with an invalid file the test passes but prints an error to the console.
The test:
test('Select an invalid file - JSON error', async () => {
const testFile = testFileBuilder.errorJSON();
storeTester.dispatch(fileSelected(testFile));
await storeTester.waitFor(FILE_ERROR);
const state = storeTester.getState().file;
expect(state.fileValidated).toBeFalsy();
expect(state.fileError).toBeTruthy();
});
The error that is printed after the test completes successfully:
e.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
Error: Error: connect ECONNREFUSED 127.0.0.1:80
at Object.dispatchError (/home/noams/dev/web/visual-log-viewer/client/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
at Request.client.on.err (/home/noams/dev/web/visual-log-viewer/client/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:676:20)
at Request.emit (events.js:194:15)
at Request.onRequestError (/home/noams/dev/web/visual-log-viewer/client/node_modules/request/request.js:881:8)
at ClientRequest.emit (events.js:189:13)
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19) undefined
Any subsequent file validation tests fail.
I'd appreciate any advice of how to tackle this issue.

Titanium appcelerator module not found

I'm facing an error when building my titanium appcelerator application for android, below are modules installed :
- modules
Android > com.pushwoosh.module and dk.napp.drawer
tiapp.xml
<modules>
<module platform="iphone">dk.napp.drawer</module>
<module platform="android">dk.napp.drawer</module>
...
When i build the app, and run it from device i get following error :
[ERROR] : TiExceptionHandler: (main) [60613,103255] ----- Titanium Javascript Runtime Error -----
[ERROR] : TiExceptionHandler: (main) [1,103256] - In ti:/module.js:303,2
[ERROR] : TiExceptionHandler: (main) [0,103256] - Message: Uncaught Error: Requested module not found: dk.napp.drawer
[ERROR] : TiExceptionHandler: (main) [0,103256] - Source: throw new Error("Requested module not found: " + request); // TODO Set 'code' property to 'MODULE_NOT_FOUND' to match Node?
[ERROR] : V8Exception: Exception occurred at ti:/module.js:303: Uncaught Error: Requested module not found: dk.napp.drawer
[ERROR] : ViewRootImpl: sendUserActionEvent() mView == null
So i don't know why the app doesn't found the dk.app.drawer module, here is a screenshot of all modules:
Thanks again for your helps
In the screenshot you only show the version 1.2.4 which is the iOS version. Did you add the android version too?
https://github.com/viezel/NappDrawer/tree/master/android/dist

Casper JS : Strange error: status=fail (HTTP 200)

I'm trying to load the following webpage with casperjs/phantomjs http://m.10bet.com/#leage_panel#10096.
Therefore I wrote the following simple casper script:
var casper = require('casper').create({
verbose: true,
logLevel: "debug"
});
if( casper.cli.args.length != 1 )
casper.echo('No URL as arguments given. Exiting.\n').exit();
var id = casper.cli.args[0]
casper.start( 'http://m.10bet.com/#leage_panel#' + id, function() {
casper.waitForResource("http://m.10bet.com/pagemethods.aspx/UpdateEvents", function() {
this.echo(casper.getPageContent())
}, function(){}, function(){}, 10000 );
});
casper.run(function() {
this.echo('Done.').exit();
});
So, I'm waiting for the last resource to be loaded which is in this case "http://m.10bet.com/pagemethods.aspx/UpdateEvents". I checked this with the chrome developer tools. Subsequently I want to output the rendered html on the console.
However, but instead of the html I get a in my opinion very strange error:
solaris:js_loaders Tom$ casperjs 10bet_loader.js 10096
2014-01-03 17:31:36.545 phantomjs[8733:130b] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: http://m.10bet.com/#leage_panel#10096, HTTP GET
[debug] [phantom] Navigation requested: url=http://m.10bet.com/#leage_panel#10096, type=Other, lock=true, isMainFrame=true
[debug] [phantom] url changed to "http://m.10bet.com/#leage_panel#10096"
[debug] [phantom] Navigation requested: url=http://m.10bet.com/#leage_panel#10096, type=Reload, lock=true, isMainFrame=true
[warning] [phantom] Loading resource failed with status=fail (HTTP 200): http://m.10bet.com/#leage_panel#10096
[debug] [phantom] Successfully injected Casper client-side utilities
[debug] [phantom] url changed to "http://m.10bet.com/#leage_panel#10096"
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step 2/2 http://m.10bet.com/#leage_panel#10096 (HTTP 200)
[info] [phantom] Step 2/2: done in 761ms.
[info] [phantom] Step 3/3 http://m.10bet.com/#leage_panel#10096 (HTTP 200)
[info] [phantom] Step 3/3: done in 771ms.
[warning] [phantom] Casper.waitFor() timeout
[info] [phantom] Done 3 steps in 790ms
Done.
solaris:js_loaders Tom$
As you can see from the log the error "Loading resource failed with status=fail (HTTP 200): http://m.10bet.com/#leage_panel#10096" gives a http 200 ok but failed. Eventually the webpage is not loaded or printed on the console. So I'm wondering what is going wrong here?
Usage:
casperjs stackoverflow.js --idEvent=10096
Code:
var casper = require('casper').create ({
waitTimeout: 15000,
stepTimeout: 15000,
verbose: true,
viewportSize: {
width: 1024,
height: 768
},
pageSettings: {
"userAgent": 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.10 (KHTML, like Gecko) Chrome/23.0.1262.0 Safari/537.10',
"loadImages": false,
"loadPlugins": false,
"webSecurityEnabled": false,
"ignoreSslErrors": true
},
onWaitTimeout: function() {
casper.echo('Wait TimeOut Occured');
},
onStepTimeout: function() {
casper.echo('Step TimeOut Occured');
}
});
//vars
var idEvent = casper.cli.get('idEvent');
// start
casper.start();
// check args
casper.then(function() {
if (!idEvent) {
//usage check
this.echo('Invalid usage: Must supply Event Id');
casper.exit();
}
});
casper.thenOpen('http://m.10bet.com/#leage_panel#' + idEvent, function() {
casper.waitForResource('http://m.10bet.com/pagemethods.aspx/UpdateEvents', function() {
//casper.waitForSelector('#league_block', function() {
}, function then() { //selector found
this.echo(casper.getPageContent());
casper.exit();
}, function timeout() { //selector not found
this.echo("Timeout On Selector...Exiting").exit();
});
});
// executes
casper.run();
Does your arguments work in other scripts? I'm curious because the documentation shows that arguments are referenced in this way.
casper.echo(casper.cli.has(0));
I'm wondering if maybe this is the issue?