I'm trying to scrape data from this web page... "http://agmarknet.nic.in/mark2_new.asp"
I need to type in "banana" in the commodity search and click the "Go" button.
With the help of Stack Overflow, I'm able to bring up Firefox, type in "Banana"...but the "Go" button (Go3 based on the inspection) WILL NOT FIRE!!
I've tried element.click(), I've tried ActionChains, I've tried moving the cursor to the element, I've verified it's enabled. It just will not go to the next search page.
The OTHER search button (B1...which is a generic search) sort of works...except that when selenium clicks it, it brings up a different page than when I click it manually...so that's weird too.
I DON'T get any errors...it just does not go to the next page.
Thanks in advance for any help you can offer. It's driving me crazy!
def SLEEP(num):
for i in range(0,num,1):
print ".",
time.sleep(1)
def click_button(driver, button_name):
assert driver.find_element_by_name(button_name)
button = driver.find_element_by_name(button_name)
if button.is_enabled():
print "it is enabled"
else:
print "IT IS NOT ENABLED"
# Try with element
button.click()
#Try with action chain
action = ActionChains(driver)
action.move_to_element(driver.find_element_by_name(button_name))
action.click(driver.find_element_by_name(button_name))
action.perform()
# WORKS
driver = webdriver.Firefox()
driver.get("http://agmarknet.nic.in/mark2_new.asp")
SLEEP(5)
assert "AG" in driver.title
print driver.title
# WORKS
textinput = driver.find_element_by_name('cmm')
textinput.send_keys("banana")
SLEEP(5)
# SORT OF WORKS (brings up unexpected page)
button_name = "B1"
click_button(driver, button_name)
# DOES NOT WORK
button_name = "Go3"
click_button(driver, button_name)
button.click()
works for me. Note that you don't need to puttime.sleep
between actions:Also, instead of
click()
you can push space button:Hope that helps.