0

it's login is fine, but i am not able to track the issue, here the code below

    while True:
        time.sleep(10)
        browser.get("https://www.instagram.com/accounts/edit/?wo=1")

I am getting this error when i ran project.py

Superuser$ python project.py

user diabruxaneas1989 with proxy 192.126.184.130:8800 running 

Traceback (most recent call last):
File "project.py", line 158, in <module>
Main()
File "project.py", line 94, in Main
username = browser.find_element_by_id('id_username')
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 269, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 745, in find_element
{'using': by, 'value': value})['value']
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
 selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"id_username"}
Stacktrace:
at FirefoxDriver.prototype.findElementInternal_ (file:///var/folders/rc/vx_d14f14p97l02f35j6_dvw0000gn/T/tmp6I93xt/extensions/[email protected]/components/driver-component.js:10770)
at FirefoxDriver.prototype.findElement (file:///var/folders/rc/vx_d14f14p97l02f35j6_dvw0000gn/T/tmp6I93xt/extensions/[email protected]/components/driver-component.js:10779)
at DelayedCommand.prototype.executeInternal_/h (file:///var/folders/rc/vx_d14f14p97l02f35j6_dvw0000gn/T/tmp6I93xt/extensions/[email protected]/components/command-processor.js:12661)
at DelayedCommand.prototype.executeInternal_ (file:///var/folders/rc/vx_d14f14p97l02f35j6_dvw0000gn/T/tmp6I93xt/extensions/[email protected]/components/command-processor.js:12666)
at DelayedCommand.prototype.execute/< (file:///var/folders/rc/vx_d14f14p97l02f35j6_dvw0000gn/T/tmp6I93xt/extensions/[email protected]/components/command-processor.js:12608)  

I tried other solutions as well but still same error .

Any help would be appreciated, Thanks

2

2 Answers 2

1

You need to start using the wait variable which is an instance of WebDriverWait class:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(browser, 10)
username = wait.until(EC.visibility_of_element_located((By.ID, 'id_username')))

This would wait until the username input becomes visible.

Sign up to request clarification or add additional context in comments.

Comments

1

you said in comments that the page is https://www.instagram.com/accounts/login/?force_classic_login, but in your code you use browser.get("https://www.instagram.com/accounts/edit/?wo=1"), obviously it's not the same page and your problem might be that in https://www.instagram.com/accounts/edit/?wo=1 there is no element with id id_username while on page https://www.instagram.com/accounts/login/?force_classic_login there is element with id id_username.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.