Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
selenium & weblinks help
#3
(Oct-18-2020, 01:04 PM)snippsat Wrote: find_element_by_css_selector() return a list.
Don't need a .click() on search_bar.
Also add delay before trying to get content in link time.sleep a fast first way when testing,or look at Waits
browser.get('https://duckduckgo.com')
search_bar = browser.find_elements_by_css_selector('#search_form_input_homepage')[0]
#search_bar.click()
search_bar.send_keys('liveleak')
search_bar.submit()
time.sleep(3)
first_link = browser.find_elements_by_css_selector('#r1-0 > div:nth-child(1) > h2:nth-child(1) > a:nth-child(1)')
print(first_link[0].text)
Output:
LiveLeak.com - Redefining the Media

thank you , i was getting frustrated with this i kept going over and over the html link , i thought i was about to have to start taking html and css classes : ) just to figure this out.
snippsat likes this post
Reply


Messages In This Thread
selenium & weblinks help - by gr3yali3n - Oct-18-2020, 10:51 AM
RE: selenium & weblinks help - by snippsat - Oct-18-2020, 01:04 PM
RE: selenium & weblinks help - by gr3yali3n - Oct-18-2020, 03:23 PM
RE: selenium & weblinks help - by gr3yali3n - Oct-21-2020, 05:50 AM
RE: selenium & weblinks help - by snippsat - Oct-21-2020, 08:15 AM
RE: selenium & weblinks help - by gr3yali3n - Nov-05-2020, 05:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 3,687 Nov-03-2017, 08:41 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