silverAndroid / drivetest-ca-availabilities

A Node.js script for seeing which dates are available for driving test centers around Ontario

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read property 'url' of undefined

skalitin opened this issue Β· comments

Describe the bug
An "TypeError: Cannot read property 'url' of undefined" on attempt to parse bookingDateResponse. Stack trace and log output:

C:\Temp\drivetest-ca-availabilities>yarn start -m 3 -l 43.41164387982603,-79.73245219532673 -r 5 --chromiumPath "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
yarn run v1.22.11
$ node cli.js -m 3 -l 43.41164387982603,-79.73245219532673 -r 5 --chromiumPath "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
INFO (24668 on DESKTOP-CRQBOB1): Checking for updates...
INFO (24668 on DESKTOP-CRQBOB1): No new updates found, current version 1.3.1
INFO (24668 on DESKTOP-CRQBOB1): Please pass the HCaptcha to continue...
INFO (24668 on DESKTOP-CRQBOB1): Waiting to be allowed to leave waiting room...
INFO (24668 on DESKTOP-CRQBOB1): Logging in...
INFO (24668 on DESKTOP-CRQBOB1): Finding available times for a G exam
INFO (24668 on DESKTOP-CRQBOB1): Going to be searching these DriveTest centers: Oakville
INFO (24668 on DESKTOP-CRQBOB1): If you appreciate my work, feel free to buy me a β˜•οΈ (coffee) here 😊: https://www.buymeacoffee.com/rushilperera
ERROR (24668 on DESKTOP-CRQBOB1): TypeError: Cannot read property 'url' of undefined
    at findAvailableDates_1 (C:\Temp\drivetest-ca-availabilities\scraper.js:203:64)
    at findAvailableDates_1.next (<anonymous>)
    at resume (C:\Temp\drivetest-ca-availabilities\scraper.js:36:44)
    at fulfill (C:\Temp\drivetest-ca-availabilities\scraper.js:38:31)
error Command failed with exit code 1.

To Reproduce
Steps to reproduce the behavior:

  1. Start with the command line above and wait for some time in the waiting room
  2. See error

Expected behavior
No error

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Edge 92.0.902.67

scraper.js:203:64 is this line:

Number(new URLSearchParams(bookingDateResponse.url().split("?").pop()).get("month")) - 1;

Just noticed there is a log file too:

{"level":30,"time":1628704223338,"pid":24668,"hostname":"DESKTOP-CRQBOB1","msg":"Going to be searching these DriveTest centers: Oakville"}
{"level":20,"time":1628704223356,"pid":24668,"hostname":"DESKTOP-CRQBOB1","msg":"received response locations"}
{"level":20,"time":1628704223363,"pid":24668,"hostname":"DESKTOP-CRQBOB1","msg":"Attempt 1: calling selectLocation"}
{"level":20,"time":1628704223364,"pid":24668,"hostname":"DESKTOP-CRQBOB1","msg":"clicking a[id=\"9580\"]"}
{"level":20,"time":1628704223431,"pid":24668,"hostname":"DESKTOP-CRQBOB1","msg":"clicking #booking-location > div > div > form > div.form-group.loc-submit > div.directive_wrapper.ng-isolate-scope > button"}
{"level":20,"time":1628704223464,"pid":24668,"hostname":"DESKTOP-CRQBOB1","msg":"Called selectLocation successfully"}
{"level":20,"time":1628704223464,"pid":24668,"hostname":"DESKTOP-CRQBOB1","msg":"waiting for response with dates for location"}
{"level":10,"time":1628704228467,"pid":24668,"hostname":"DESKTOP-CRQBOB1","msg":"failed to wait for response"}

commented

Hello, I got a similar error, except 'Cannot read property of json' instead of 'url'. Here is what happened after I was able to leave the waiting room:

INFO (5740 on MacBook-Pro.local): Logging in... INFO (5740 on MacBook-Pro.local): Finding available times for a G exam INFO (5740 on MacBook-Pro.local): Going to be searching these DriveTest centers: Barrie, Clinton, Collingwood, Guelph, Guelph Temporary Testing Site, Kitchener, Orillia, Owen Sound, Parry Sound, Stratford, Walkerton INFO (5740 on MacBook-Pro.local): Searching August at location Barrie INFO (5740 on MacBook-Pro.local): Searching September at location Barrie INFO (5740 on MacBook-Pro.local): Searching October at location Barrie INFO (5740 on MacBook-Pro.local): Searching November at location Barrie INFO (5740 on MacBook-Pro.local): Searching December at location Barrie ERROR (5740 on MacBook-Pro.local): Attempt 1 to call selectLocation failed...waiting 1 second INFO (5740 on MacBook-Pro.local): Searching August at location Clinton INFO (5740 on MacBook-Pro.local): If you appreciate my work, feel free to buy me a β˜•οΈ (coffee) here 😊: https://www.buymeacoffee.com/rushilperera ERROR (5740 on MacBook-Pro.local): TypeError: Cannot read property 'json' of undefined at findAvailableDates_1 (/snapshot/drivetest-ca-availabilities/scraper.js) at findAvailableDates_1.next (<anonymous>) at resume (/snapshot/drivetest-ca-availabilities/scraper.js) at fulfill (/snapshot/drivetest-ca-availabilities/scraper.js)

(sorry for the poor formatting, not sure why the line breaks are being removed when I try to post code.)

Will try and investigate this issue once the website decides to be a bit more cooperative πŸ˜‚

@skalitin @tn133 could you take a look at the new release I made and see if it fixes your issue?

Closing as stale