Oct-12-2018, 02:23 AM
res
will return None as mention.This is not how you send source to BS,it's done by using
browser.page_source
.If i test it also have to push agree button before can move on.
from selenium import webdriver from selenium.webdriver.common.keys import Keys import bs4 browser = webdriver.Chrome() browser.get('http://www.yahoo.com') assert 'Yahoo' in browser.title agree = browser.find_element_by_xpath('/html/body/div[1]/div[2]/div[4]/div/div[2]/form[1]/div/input') agree.click() elem = browser.find_element_by_name('p') # find the search box res = elem.send_keys('seleniumhq' + Keys.RETURN) print(repr(res))
Output:None
It should look like this.soup = bs4.BeautifulSoup(browser.page_source, "html.parser")