Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No element found for selector #64

Open
ghassenelkamel opened this issue Jun 15, 2023 · 14 comments
Open

No element found for selector #64

ghassenelkamel opened this issue Jun 15, 2023 · 14 comments

Comments

@ghassenelkamel
Copy link

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
Copy link

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
Copy link

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
Copy link

IggsGrey commented Sep 5, 2023

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
Copy link

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
Copy link

naihloan commented Mar 20, 2024

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.

  • Where in folders and files, and lines, should we place this line of code?

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
Copy link

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

@naihloan
Copy link

@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
Copy link

@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
Copy link

~/Public/linkedin-easy-apply-bot$ npm run start

> [email protected] 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
Copy link

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
Copy link

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
Copy link

I see the window popup, but it's chromium

@IggsGrey
Copy link

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
Copy link

IggsGrey commented Apr 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants