python - Changing the xpath by taking elements from a list -
i doing web scraping , trying scrape using xpath , selenium. xpath can changed changing have stored in list. wanted create loop can automatically change xpath , find contents. tried this, somewhere going wrong.
packages= ["evenings_and_weekend_extra", "anytime_extra"] in packages: name= driver.find_element_by_xpath('//*[@id="productbuttoncontrols_st_"+i]/label') print name.text
instead of "evenings_and_weekend_extra", want different elements in list packages.
#this required xpath needs altered //*[@id="productbuttoncontrols_st_evenings_and_weekend_extra"]/label'
try insert values xpath
expression below:
packages= ["evenings_and_weekend_extra", "anytime_extra"] in packages: name= driver.find_element_by_xpath('//*[@id="productbuttoncontrols_st_%s"]/label' % i) print name.text
Comments
Post a Comment