1(我想选择下拉选项1并进行搜索(单击(,然后返回上一页,从下拉列表中选择下一个选项2并进行搜索(单击(,我想做同样的事情直到最后一个下拉列表。
2(我尝试使用for循环,它适用于第一个选项1,循环可以从下拉列表中选择选项1并进行搜索(单击(,下次循环找不到下拉选项。
3(你能帮忙解决问题吗?
driver.find_element_by_id("seller_inventory_add_product_onebyone_inputSearchProduct").send_keys("Mobile")
driver.find_element_by_id("inventory_obosearch_go_item_search").click()#next button
print "next button clicled"
selement = driver.find_element_by_id("seller_inventory_add_product_onebyone_selectProductGroupName")
all_optionss = selement.find_elements_by_tag_name("option")
time.sleep(2)
i=0
for j in all_optionss:
print "test the loop"
selement = driver.find_element_by_id("seller_inventory_add_product_onebyone_selectProductGroupName")
all_optionss = selement.find_elements_by_tag_name("option")
time.sleep(3)
if (i < 24):
print "2nd time loop"
time.sleep(2)
j.click()
print j.text
time.sleep(4)
print "before passing value"
var4 = driver.find_element_by_id("seller_inventory_add_product_onebyone_inputSearchProduct")
print "before sending value"
time.sleep(4)
var4.clear()
time.sleep(4)
var4.send_keys(j.text)
time.sleep(4)
print "after sending values"
driver.find_element_by_id("inventory_inputSearchProduct_go").click()#next button
print "next button clicled"
time.sleep(4)
selement = driver.find_element_by_id("seller_inventory_add_product_onebyone_selectProductGroupName").click
print "finding the options"
else:
break
它会
在新页面/选项卡中打开吗? 如果没有,您可以通过上一个按钮返回页面
driver.execute_script("window.history.go(**x**)")
其中 x = 页数,例如,如果您需要返回 2 页,值应为 -2