Fill a form without name
Closed this issue · 1 comments
hsch0 commented
I want to fill in the city name on www.forecast.io but the field has no name:
<div class="location_controls">
<input class="location_field" placeholder="Enter a location" x-webkit-speech="" type="text">
<div class="clear pictos">*</div>
</div>
my python code
import ghost
g = ghost.Ghost()
with g.start(wait_timeout=20) as session:
page, extra_resources = session.open("http://forecast.io")
if page.http_status == 200:
print("Good!")
print session.content
# Waits for form search field
session.wait_for_selector('.location_field')
# Fills the form
session.fill('.location_field', {'???': 'Berlin'})
# Submits the form
session.call(".location_field", "submit")
session.capture_to('forecast.png')
hsch0 commented
ok, I got it working with:
session.evaluate("document.getElementsByClassName('location_field')[0].value='Berlin';")