Web scraping in python (.aspx)

369 Views Asked by At

I want to automate this web-site https://www.avis.co.in by sending it pre defined values from my code. But the thing is that I am not able to send the text in the delivery address textbox.

from latlong import user
from lib import *

locality, city = user.split()

city = city.upper()
locality = locality.upper()


binary = FirefoxBinary('/usr/lib/firefox/firefox')
driver = webdriver.Firefox(firefox_binary=binary)

driver.get("https://www.avis.co.in")

driver.switch_to.window(driver.window_handles[-1])

driver.switch_to.window(driver.window_handles[0])

driver.find_element_by_xpath("//select[@id='DrpCity' and @name='DrpCity']/option[text()='Pune']").click()

user_box = driver.find_element_by_xpath("//select[@id='txtPickUp' and @name='txtPickUp']/[text()='XYZ']")

Whenever I am sending XYZ, the textbox (delivery address) refreshes itself. I have tried a lot of things but can't come up with a solution.

1

There are 1 best solutions below

0
On

The problem is that you can't set the text in the element within the locator. Try this:

# Get the element object
user_box = driver.find_element_by_id("txtPickUp")
# Send text to the element.
user_box.send_keys("XYZ")