Hello,
I am new to python and selenium webdriver and I am completely flummoxed by locating elements in a web page. For instance, I am trying to input a search term in the search box of the home page of macrumors: the code in the webpage has this section in it:
<div class="search">
<span class="icon"></span>
<form class="search-form" action="https://www.macrumors.com/search">
<input type="text" class="bginput" name="s" size="20" placeholder="Search
My python code is this:
Does anyone know why this does not work? it opens Firefox and Macrumors but then does nothing and finished. Many thanks!
I am new to python and selenium webdriver and I am completely flummoxed by locating elements in a web page. For instance, I am trying to input a search term in the search box of the home page of macrumors: the code in the webpage has this section in it:
<div class="search">
<span class="icon"></span>
<form class="search-form" action="https://www.macrumors.com/search">
<input type="text" class="bginput" name="s" size="20" placeholder="Search
My python code is this:
Code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
# Go to Macrumors
driver.get('http://macrumors.com')
# Select the search box
python_link = driver.find_element_by_name('s')
python_link.send_keys('hello world!')
Does anyone know why this does not work? it opens Firefox and Macrumors but then does nothing and finished. Many thanks!
Last edited: