I am trying to scrape the contents using selenium and since the xpaths are similar, i am using a list so that i don't need to write 'find_element_by_xpath'. I wrote a function to get the contents but the contents are not getting extracted. Here is my code:
def find_text(path):
driver.find_element_by_xpath(path).text
ph_packages= ["PAY_AS_YOU_TALK", "EVENINGS_AND_WEEKEND_EXTRA"]
for i in ph_packages:
ph_name.append(find_text('//*[@id="productButtonControls_ST_%s"]/label' % i))
print ph_name
There is no output with this code but when i used the same code without the function, then it is working totally fine.
ph_packages= ["PAY_AS_YOU_TALK", "EVENINGS_AND_WEEKEND_EXTRA"]
for i in ph_packages:
ph_name.append(driver.find_element_by_xpath('//*[@id="productButtonControls_ST_%s"]/label' % i).text)
I think i am doing some mistake with writing the function. Could someone help me with this?