Python Forum

Full Version: Get element (ID) from website to login
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

Can you help me to get the element name from the website that I want to log-in to? I tried everything...:( I tried username, email, login-username, mat-input-0

Code for Python is:

from selenium import webdriver

browser = webdriver.Chrome()

browser.get("")

username = browser.find_element_by_name("")

username.click()

username.send_keys("")
Code from website element is

<input matinput type="email" formcontrolname="username" test-id="login-username" class="mat-input-element mat-form-field-autofill-control ng-tns-c185-3 cdk-text-field-autofill-monitored ng-pristine ng-invalid ng-touched" id="mat-input-0" placeholder="Username / email" aria-invalid="true" aria-required="false">
Im getting the error:
Error:
Traceback (most recent call last): File "login.py", line 32, in <module> username = browser.find_element_by_name("username") File "C:\Users\Example\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 496, in find_element_by_name return self.find_element(by=By.NAME, value=name) File "C:\Users\Example\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { File "C:\Users\Example\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\Example\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="username"]"} (Session info: chrome=84.0.4147.89)
what is the URL?
you seem to be missing a lot of code.
Suggest that you read (especially part 2 for selenium):
web scraping part 1
web scraping part 2
(Jul-26-2020, 09:41 PM)Larz60+ Wrote: [ -> ]what is the URL?
you seem to be missing a lot of code.
Suggest that you read (especially part 2 for selenium):
web scraping part 1
web scraping part 2

I know I'm missing some code ;) But I cant find the ID element. The URL is URL

When the side loades, it comes with somekind of pop-up, maybe there it goes wrong?

Thanks!
take the two tutorials, doesn't take much time at all, and all will become clear once you understand the basics.
You will be able to find your tag if it's there.
Olimpiarob

Why don't you try to use Selenium IDE from your brownser? It's a plugin from Selenium.

Start a new project a simulate what you need. After that, stop the Selenium IDE and check the item that you and to use.

Catch the xpath or id that it will give for you. Look the image that I attached here. But use the id or xpath:position.

[attachment=943]

Hope it can help you!

Regards,
Martinelli