我正在编写一个自动为在线商店创建订单的代码。我正在使用Python 3和Selenium和firefox驱动程序。
0.00
0.00
0.00
0.00
973.84
973.84
973.84
1947.69
1947.69
1947.69
2921.57
2921.57
2921.57
这是告诉脚本输入特定信息的函数。我的主要问题是在最后一行
def change_address(browser,data):
ui.WebDriverWait(browser, 60).until(EC.visibility_of_element_located((By.LINK_TEXT, "Edit")))
browser.find_element_by_link_text("Edit").click()
while True:
try:
ui.WebDriverWait(browser, 5).until(EC.visibility_of_element_located((By.NAME, "contactPerson")))
break
except:
browser.find_element_by_link_text("Edit").click()
fill_field_by_name(browser,"contactPerson",unidecode.unidecode(data["Full Name (Billing)"]))
choose_option_from(browser,"#address-main > div.sa-form > div:nth-child(4) > div > select",data["Country Name (Billing)"])
try:
data["Address 1 (Billing)"] = str(int(float(data["Address 1 (Billing)"])))
except:
pass
fill_field_by_name(browser,"address",unidecode.unidecode(data["Address 1 (Billing)"]))
try:
data["Address 2 (Billing)"] = str(int(float(data["Address 2 (Billing)"])))
except:
pass
fill_field_by_name(browser,"address2",unidecode.unidecode(data["Address 2 (Billing)"]))
fill_field_by_name(browser,"city",unidecode.unidecode(data["City (Billing)"]))
if not choose_option_from(browser,"#address-main > div.sa-form > div.row.sa-form-group.sa-province-group > div > select",data["State Name (Billing)"]):
try:
fill_field_by_name(browser,"province",unidecode.unidecode(data["State Name (Billing)"]))
except:
pass
我需要的是,它不是仅仅传递,而是输入一个特定的文本,在这种情况下“ - 请选择 - ”,这样当它不识别状态时,它只选择“ - 请选择 - - “选项而不是选择任何,但我不知道该怎么做。
希望有人可以给我一些提示或指导我。谢谢!