nacimgoura / add-free-course-udemy

add automatically free course on your udemy account
MIT License
9 stars 5 forks source link

Error #6

Open c1h4n61r opened 5 years ago

c1h4n61r commented 5 years ago

Error: An element could not be located on the page using the given search parameters.

nacimgoura commented 5 years ago

This project is currently deprecated.

c1h4n61r commented 5 years ago

ok.

chaoscreater commented 4 years ago

Hi there,

I know the project is deprecated, but just wondering if there's a chance that you can update it? This does exactly what I want. I have a list of URLs for Udemy courses that have gone free for a limited time. It'll take me literally hours to go through the list and add the courses to my account. Is it possible for you to update this?

UPDATE 1:

Hmm, I somehow managed to get past the error message that I was getting earlier.

For those who are stuck on running this, you'll probably have the same error message as me, something related to "fibers". Here's what you need to do:

In file explorer, paste the following into the path: %appdata%\npm\node_modules\add-free-course-udemy

Shift + right click in the folder and open Powershell window here:

image

In the Powershell window that you just open, paste this in: npm install -g node-gyp

Next, paste this in: git clone git://github.com/laverdet/node-fibers.git cd node-fibers npm install

Now, there should be a folder called "node-fibers" under "add-free-course-udemy". You need to copy everything in that node-fobers folder and paste it in here:

%appdata%\npm\node_modules\add-free-course-udemy\node_modules\fibers

Essentially, there is a subfolder called "fibers" under "add-free-course-udemy\node_modules". What we've done is simply downloaded the latest version of "fibers" and then updated the "fibers" subfolder.

I've managed to get this:

image

I simply created a test.txt file and pasted 2 URLs in it: https://www.udemy.com/course/adobe-audition/?couponCode=MASTERADOBE https://www.udemy.com/course/the-complete-angular-course-zero-to-hero/?couponCode=ANGULAR11

Then, a new Chrome window popped up and it seems to be doing something, but then it will close itself automatically and will give you an error in Powershell, as you can see in the screenshot above. Not sure how to troubleshoot this, as I don't know much about programming at all or even know where or how to look for logs...

Also, in the Chrome window that the app/script created, if you try to create a new tab page and login to Udemy, you'll get the exact same error as discussed in this thread: https://github.com/KishanBagaria/dAbot/issues/13

The thing is, Javascript and Cookies are enabled in the settings. Chrome is running the latest version too (verified using Process Explorer).

image

image

Here, we can see the path that the "Selenium ChromeDriver" is running from. Assuming the Chromedriver is out of date, I figured I could just update it like I did with the "fibers" trick above. So, in Powershell, run this:

npm install selenium-standalone@latest -g selenium-standalone install

It should create a folder here: %appdata%\npm\node_modules\selenium-standalone

Copy the contents of that folder into here: %appdata%\npm\node_modules\add-free-course-udemy\node_modules\selenium-standalone

Then I tried running the app/script from the start again. Same issue unfortunately.

I've also noticed that in the Chrome window that gets created by the app/script, there is an extension called "Chrome automation". I'm guessing this "Selenium" thing is a way to automate web related tests using Chrome and Udemy is now smart enough to detect that you're not using Chrome properly and that you're using a script to access the website. It then presents some sort of CAPTCHA to make you confirm that you're human. But, the script just ends straight away and closes Chrome automatically. If the script can be updated to pause and then make you click on the CAPTCHA, then perhaps it will still work?

UDPATE 2:

OK, getting closer now. I took a look at the error message in Powershell, which basically is some kind of error message: Error: An element could not be located on the page using the given search parameters.

So I figured, if I take a look at the source code and find a keyword related to "error", I might be able to find the section of the code that it got stuck at. Sure enough, I found the code in the "index.js" file in the root folder. I commented out the browser.end and process.exit and now the "Selenium" Chrome window will stay open! I was able to accept the CAPTCHA and login. Subsequent logins will not prompt for Captchas anymore.

image

Unfortunately, the script isn't actually doing anything even after I'm logged in. I just get this message:

image

The URLs in my text file are working fine. They are free for a limited time. If you browse to them in a normal Chrome window, they can be added to your account no problem. I've tried other URL links too and the script just doesn't load them at all.

BTW, you can see the "C" extension icon in the window, that is Chrome automation extension and so it's definitely a Selenium chrome window:

image

chaoscreater commented 4 years ago

Can't you just take the "index" Javascript file and modify it so that we can run it as a userscript, which therefore means we can run it in any browser? The code will be much simpler, you don't need to take the user's credential, they can just be logged into Udemy manually in Chrome/Firefox and just run the userscript.