I'm trying to get to the URL behind the submit button:
from selenium import webdriver
browser = webdriver.Safari(executable_path = '/usr/bin/safaridriver')
#Fill in the required field
default_input = '111'
browser.get('https://trackapkg.com/aramex-tracking-number')
field = browser.find_element_by_xpath('//*[@id="ShipmentNumber"]')
field.send_keys(default_input)
url = browser.current_url
#Click submit button to get the new URL
browser.find_element_by_xpath("//span[@class='input-group-btn']").click();
while url == browser.current_url:
time.sleep(5)
url = browser.current_url
print(url)
Submitting works (though inconsistently), but apparently there's an issue with Xpath to the button itself so it's not clicked and the URL can't be caught. I've tried multiple variants:
browser.find_element_by_xpath("//*[@id='ShipmentNumber']/input[@class='btn btn-success']").click()
Or this:
browser.find_element_by_xpath("//input[@class='btn btn-success']").click()
But still can find the solution. I will appreciate your advice
