Я пытаюсь выяснить, как правильно получить данные для пользовательского интерфейса на веб-сайте.
Пример:
Это вывод, когда данные вводятся на веб-сайт.
Каков наилучший подход для правильного ввода этой программы данные в правильную строку?
Вот код для контекста:
orders = {}
def order_data():
# start by adding a dict to the dict with key of length dict,
# the first key will be 0, then 1, 2 and so on
orders[len(orders)] = {}
# next you can start adding data using len - 1 to access the correct key
# and so on for all your data
orders[len(orders) - 1]['handling unit'] = e3.get()
orders[len(orders) - 1]['pieces'] = e4.get()
orders[len(orders) - 1]['description'] = e5.get()
orders[len(orders) - 1]['length'] = e6.get()
orders[len(orders) - 1]['width'] = e7.get()
orders[len(orders) - 1]['height'] = e8.get()
orders[len(orders) - 1]['weight'] = e9.get()
orders[len(orders) - 1]['classification'] = e10.get()
def GetQuote():
origin_zip = e1.get()
destination_zip = e2.get()
#autofill origin zip, destination zip, and product fields
driver.implicitly_wait(1)
driver.find_element(By.XPATH, "//input[@name='originZip']").send_keys(origin_zip)
driver.find_element(By.XPATH, "//input[@name='destinationZip']").send_keys(destination_zip)
for i in range(len(orders)):
#Product
driver.find_element(By.XPATH, "/html[1]/body[1]/app-root[1]/div[1]/div[1]/app-record[1]/div[1]/div[2]/div[1]/app-record-quoting[1]/div[1]/app-record-product-list-panel[1]/form[1]/div[3]/div[1]/div[1]/div[1]/input[1]").send_keys(orders[i]['description'])
#dropdown menu for Class
select_element = Select(driver.find_element_by_xpath("/html[1]/body[1]/app-root[1]/div[1]/div[1]/app-record[1]/div[1]/div[2]/div[1]/app-record-quoting[1]/div[1]/app-record-product-list-panel[1]/form[1]/div[3]/div[1]/div[2]/div[1]/select[1]"))
driver.implicitly_wait(10)
select_element.select_by_value(orders[i]['classification'])
#dropdown menu for Handling Unit
select_element = Select(driver.find_element_by_xpath('/html[1]/body[1]/app-root[1]/div[1]/div[1]/app-record[1]/div[1]/div[2]/div[1]/app-record-quoting[1]/div[1]/app-record-product-list-panel[1]/form[1]/div[3]/div[1]/div[3]/div[1]/select[1]'))
select_element.select_by_value('1')
driver.implicitly_wait(1)
driver.find_element(By.CSS_SELECTOR, "input[formControlName=handlingQty]").send_keys(orders[i]['handling unit'])
driver.find_element(By.CSS_SELECTOR, "input[formControlName=packageQty]").send_keys(orders[i]['pieces'])
driver.find_element(By.CSS_SELECTOR, "input[formControlName=length]").send_keys(orders[i]['length'])
driver.find_element(By.CSS_SELECTOR, "input[formControlName=width]").send_keys(orders[i]['width'])
driver.implicitly_wait(1)
driver.find_element(By.CSS_SELECTOR, "input[formControlName=height]").send_keys(orders[i]['height'])
element=driver.find_element(By.CSS_SELECTOR,"input[formControlName=weight]")
element.send_keys(orders[i]['weight'])
driver.implicitly_wait(1)
#if i < len(orders):
#element.send_keys(Keys.TAB);
#this at least gets some data inputed into the second row. #have to be able to change the value of the tab index
#driver.find_element_by_css_selector("input[tabindex='1033']").send_keys(orders[i]['description'])
#driver.find_element_by_css_selector("input[tabindex='1036']").send_keys(orders[i]['handling unit'])
driver.find_element(By.XPATH, "//button[@class='btn-filled clickable']").click() #generate quote button
https://ondemand.shiprite.com/record-creation
Проверка кода элемента:
#Product entry field
<input _ngcontent-c31="" autocomplete="off" class="input productEntry productNameInputEllipsis ng-pristine ng-valid ng-touched" formcontrolname="productName" tabindex="1020" id="productNameInput0">
#Generated Product entry field
<input _ngcontent-c31="" autocomplete="off" class="input productEntry productNameInputEllipsis ng-pristine ng-valid ng-touched" formcontrolname="productName" tabindex="1033" id="productNameInput1">
Ссылка на проект https://gitlab.com/minTwin/ltl-quote-automator