Python Forum
Get element (ID) from website to login
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get element (ID) from website to login
#1
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)
Reply
#2
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
Reply
#3
(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!
Reply
#4
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.
Reply
#5
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.

   

Hope it can help you!

Regards,
Martinelli
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Login and download an exported csv file within a ribbon/button in a website Alekhya 0 2,616 Feb-26-2021, 04:15 PM
Last Post: Alekhya
  Seleniun does not work with a website element flote21 2 2,321 Jan-12-2021, 07:38 PM
Last Post: flote21
  Python Webscraping with a Login Website warriordazza 0 2,571 Jun-07-2020, 07:04 AM
Last Post: warriordazza
  Login to website kapibara 4 3,489 Jul-27-2019, 02:40 PM
Last Post: kapibara
  using webbot for website login fails loeten 2 6,354 Jan-03-2019, 07:31 AM
Last Post: loeten
  Login and access website mariolopes 7 9,151 Feb-07-2018, 09:47 AM
Last Post: mariolopes
  Using python requests module and BS4 to login on an Wordpress based website apollo 1 9,371 Feb-06-2018, 01:31 AM
Last Post: metulburr
  locating element with selenium after login sumandas89 1 3,607 Jan-15-2018, 02:40 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020