Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 locating element with selenium after login
I wrote a script to locate the search bar in my facebook home page. Code for login into my facebook profile using selenium worked perfectly. I got the home page, but the code for locating the search bar is not working correctly. I tried the to locate the search bar using the following code -

elem = driver.find_element_by_name("q")
and I am getting the below error message -
/usr/bin/python2.7 /home/csurv_4/PycharmProjects/web_parsing/ Traceback (most recent call last): File "/home/csurv_4/PycharmProjects/web_parsing/", line 14, in <module> elem = driver.find_element_by_name("q") File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/", line 487, in find_element_by_name return self.find_element(by=By.NAME, value=name) File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/", line 955, in find_element 'value': value})['value'] File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/", line 312, in execute self.error_handler.check_response(response) File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/", line 237, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [name="q"]
What is the reason of this error? and what is the solution?
You either 1) didnt give it time to locate that element (add a time.sleep(3) before finding the name to test to make sure its loaded) or you can try the xpath

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python-selenium script for automated web-login does not work hectorKJ 2 383 Sep-10-2019, 01:29 PM
Last Post: buran
  Python Selenium getting table element trengan 2 2,073 Dec-31-2018, 03:02 PM
Last Post: trengan
  Click Element if displayed using Selenium and Python giaco__mar 1 831 Dec-27-2018, 06:19 PM
Last Post: metulburr
  Selenium stale element reference test 1 594 Sep-19-2018, 10:19 PM
Last Post: test
  Simple Element Check Code in Selenium Not Working digitalmatic7 1 834 Feb-18-2018, 06:53 AM
Last Post: metulburr
  Selenium - Googlemaps element not visible Barnettch3 3 2,028 Jan-15-2018, 08:07 PM
Last Post: Barnettch3
  [Selenium] Element Visible / Invisible | Delay - Best Settings? digitalmatic7 2 2,326 Nov-19-2017, 03:54 PM
Last Post: digitalmatic7
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 1,069 Nov-03-2017, 08:41 PM
Last Post: metulburr
  unable to login with selenium metulburr 4 2,467 Nov-30-2016, 04:56 AM
Last Post: metulburr
  Selenium - "Element is not currently visible and may not be manipulated" tkj80 2 8,411 Oct-27-2016, 06:04 AM
Last Post: snippsat

Forum Jump:

Users browsing this thread: 1 Guest(s)