joaosilvalopes / linkedin-easy-apply-bot

MIT License
160 stars 58 forks source link

No element found for selector #64

Open ghassenelkamel opened 1 year ago

ghassenelkamel commented 1 year ago

Issue Description

Error: No element found for selector: input[id*="jobs-search-box-keyword-id"]

Problem

When running the npm run start command, the script encounters an error while interacting with the LinkedIn website. It fails to find an input element with the selector input[id*="jobs-search-box-keyword-id"].

Steps to Reproduce

  1. Execute the command npm run start.
  2. Observe the error message mentioned above.

Expected Behavior

The script should be able to locate the input element with the selector input[id*="jobs-search-box-keyword-id"] on the LinkedIn page.

Actual Behavior

The script throws an error indicating that it cannot find the specified input element.

Requested Help

I'm seeking assistance in resolving this issue. Can someone help me understand why the script is unable to find the expected input element and provide guidance on how to fix it?

Please let me know if any additional information is required.

IggsGrey commented 1 year ago

Is the page fully rendered before the error occurs or would it still be loading.

I suspect a slow connection or device perhaps?

A video recording would be helpful for me to better understand the issue since I can't replicate it (following the concise steps you provided) on my end

MrJamieMcC commented 10 months ago

I am also having the exact same issue. The script worked before however i am now getting this issue. My setup/device hasn't changed and i have tried this on a gigabit LAN connection so my connection speed isn't the issue

IggsGrey commented 10 months ago

Hi @MrJamieMcC , I encountered this issue a few days ago myself.

The problem is that the page is being rendered too slow and the selector is being searched for too early, what you can do (temporarily) while we wait for @joaosilvalopes to respond is to add a delay before the selector.

fetchJobLinksUser.ts:13

await new Promise((resolve) => setTimeout(resolve, 5e3));

This adds a 5 second delay right before the selector is found.

MrJamieMcC commented 10 months ago

Hi @MrJamieMcC , I encountered this issue a few days ago myself.

The problem is that the page is being rendered too slow and the selector is being searched for too early, what you can do (temporarily) while we wait for @joaosilvalopes to respond is to add a delay before the selector.

fetchJobLinksUser.ts:13

await new Promise((resolve) => setTimeout(resolve, 5e3));

This adds a 5 second delay right before the selector is found.

Thank you for this quick fix <3

naihloan commented 3 months ago

Hi @MrJamieMcC , I encountered this issue a few days ago myself.

The problem is that the page is being rendered too slow and the selector is being searched for too early, what you can do (temporarily) while we wait for @joaosilvalopes to respond is to add a delay before the selector.

fetchJobLinksUser.ts:13

await new Promise((resolve) => setTimeout(resolve, 5e3));

This adds a 5 second delay right before the selector is found.

This is great input!

Still, I can't make it to work.

Thanks in advance!

PS. I'm not even trying to send the bot to work. I've been attempting only to use the npm run start command for testing (instead of npm run apply). Also, I'm simply adding my credentials, but it seems the code here in GitHub isn't working for me as is.

cc @MrJamieMcC @joaosilvalopes @IggsGrey

IggsGrey commented 3 months ago

@naihloan check in /fetch/fetchJobLinksUser.ts. place the line of code before what is currently on line 13

naihloan commented 3 months ago

@IggsGrey thanks for the quick reply!

I did that modification as suggested, and the result was always the same: no element found for selector. I even applied the change in different lines, from 12 to 20, one check per time.

Is there another way in which I can provide more information to reproduce the issue and perhaps be able to solve it? Is the original code working for others as is? What may I be doing wrong?

IggsGrey commented 3 months ago

@naihloan that looks like it might be resulting from a different missing element.

You should try debugging to find which html element it is trying to find...

or you could just share a screenshot of your terminal with the error message

naihloan commented 3 months ago
~/Public/linkedin-easy-apply-bot$ npm run start

> scripts@1.0.0 start
> ts-node ./scripts/apply.ts

> Logged in to LinkedIn
press enter to pause the program
Error: No element found for selector: input[id*="jobs-search-box-keyword-id"]
    at assert (/home/nilon/Public/linkedin-easy-apply-bot/node_modules/puppeteer-core/src/util/assert.ts:29:11)
    at IsolatedWorld.type (/home/nilon/Public/linkedin-easy-apply-bot/node_modules/puppeteer-core/src/common/IsolatedWorld.ts:348:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getJobSearchMetadata (/home/nilon/Public/linkedin-easy-apply-bot/fetch/fetchJobLinksUser.ts:14:3)
    at async fetchJobLinksUser (/home/nilon/Public/linkedin-easy-apply-bot/fetch/fetchJobLinksUser.ts:51:39)
    at async /home/nilon/Public/linkedin-easy-apply-bot/scripts/apply.ts:69:45
naihloan commented 3 months ago

I'm now under the suspicion that this could never run as long as I have 2FA enabled.

Just now, when I ran the code, I received an alert in my email that I needed to allow access. I was already signed in and enabled access again, and all the same, I wasn't able to complete the flow with npm run start. Can anyone run the code with 2FA, or am I missing the target?

IggsGrey commented 3 months ago

That's weird. The only time I run into issues with 2fa is when I try to run it in headless mode. Do you get a chrome window popup when you npm run start? If not then try npm run apply

naihloan commented 3 months ago

I see the window popup, but it's chromium

IggsGrey commented 3 months ago

shouldn't be a problem. In this case it looks like you have 2fa enabled all the time.. I'm not familiar with linkedin's 2fa settings so this is just a guess.

Also it's possible your IP is not trusted, perhaps you're connected to a VPN or using a public WIFI network.

But yeah... the case here is the 2fa that is being triggered. Perhaps in the future it should be possible to pause the script to allow you to complete 2fa.

IggsGrey commented 3 months ago

for anyone else in the future who encounters this issue, here's a fork I'm maintaining