I am new to selenium automation and while learning radio button handling in selenium, I tried to automate language setting in amazon.in page. I am unable to select the radio button listed in the page.
site: https://www.amazon.in/customer-preferences/edit?ie=UTF8&preferencesReturnUrl=%2F&ref_=topnav_lang
code used: driver.findElement(By.xpath(“//input[@value = ‘ta_IN’]”)).click(); (I tried to select the language tamil- TA (3rd radio button)). Can anyone guide me in this?
public class seleniumTutorial2 { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver","C:\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://www.amazon.in/customer-preferences/edit?ie=UTF8&preferencesReturnUrl=%2F&ref_=topnav_lang"); driver.manage().window().maximize(); driver.findElement(By.xpath("//input[@value = 'ta_IN']")).click(); } } '''
Advertisement
Answer
try using this xpath://span[text() = ‘TA’]
driver.findElement(By.xpath(“//span[text() = ‘TA’]”)).click();