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 such element #156

Open
professor1478 opened this issue Mar 1, 2023 · 2 comments
Open

no such element #156

professor1478 opened this issue Mar 1, 2023 · 2 comments

Comments

@professor1478
Copy link

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@autocomplete="username"]"}

how can I slove this? I encountered this error today. is there anyone else who solve it?

@02
Copy link

02 commented Mar 22, 2023

Running headless didn't work for me, so call the function with headless=False. I also needed to add another 10 sec sleep() just before the line that throws the exception (you can also just up the wait time, to like 10.)
Fixed it for me.

@02
Copy link

02 commented Mar 22, 2023

Adding the following in init_driver() fixes the headless issue. I think the main issue is that Selenium sends "I'm headless" in the user-agent, and Twitter notices.

        options.add_argument('user-agent="MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"')
        options.add_argument("--window-size=1920,1080");
        options.add_argument("--disable-extensions");
        options.add_argument("--proxy-server='direct://'");
        options.add_argument("--proxy-bypass-list=*");
        options.add_argument("--start-maximized");
        options.add_argument("--headless");

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

2 participants