I am encountering a challenge when attempting to post events to websites from my database using the mechanize gem. The issue lies in the fact that many of the required inputs lack a name attribute. Despite trying different methods to select them through css, they consistently return null. Here is a snippet of my code:
require 'mechanize'
#navigate to sign in page
puts "Running....."
agent = Mechanize.new { |agent|
agent.user_agent_alias = "Mac Safari"
}
page = agent.get('http://events.ctpost.com/home')
puts page.uri
link = page.link_with(text:'Add Event')
page = link.click
puts page.uri
#--------Enter sign in credentials----------
#enter email
form = page.forms.first
form['email'] = 'myemail'
#enter password
form = page.forms[1]
form['password'] = 'password'
page = form.submit
puts page.uri
pp page
#-------Create Event-------
#fill out event form
event_title = "House Show"
event_description = "House show at Joe's House"
event_venue = "Joes House"
event_date = "03/14/2018"
event_start_time = "7:00pm"
form = page.forms.first
form['title'] = event_title
form['description'] = event_description
form['price'] = "free"
form['phone'] = "666-666-6666"
form['event_venue'] = event_venue
and here is the element I am trying to select:
<input id="startTime" type="text" placeholder="* Start Time" class="required input-full time ui-timepicker-input" autocomplete="off">
Is there a way to target this element using its id or other css attributes? My experience with mechanize is limited. Appreciate any help in advance.