How to select a country from https://www.aliexpress.com/ ship to drowdown menu using Selenium and Python

后端 未结 3 1512
陌清茗
陌清茗 2020-12-12 03:52

On the website https://www.aliexpress.com, I need to change the country from the dropdown menu using selenium


         


        
3条回答
  •  清歌不尽
    2020-12-12 04:18

        import org.openqa.selenium.Alert;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    
    import java.util.List;
    
    public class aliexpress {
    
        public static void main(String[] args) throws Exception {
            System.setProperty("webdriver.chrome.driver", "C:\\Users\\User\\Downloads\\chromedriver83\\chromedriver.exe");
            WebDriver driver = new ChromeDriver();
    
    
            driver.manage().window().maximize();
            driver.get("https://www.aliexpress.com/");
            driver.findElement(By.xpath("//span[@class='ship-to']")).click();
            driver.findElement(By.xpath("//div[@id='nav-global']/div[4]/div/div/div/div/div/a")).click();
    
            List  lists=driver.findElements(By.xpath("//ul[@data-role='content']//li"));
            System.out.println(lists.size());
    
            for (int i = 0; i < lists.size(); i++) {
                //System.out.println(LIST.get(i).getText());
                if (lists.get(i).getText().contains("Barbados")) {
                    lists.get(i).click();
                    break;
                }
    
    
            }
        }
    }
    

提交回复
热议问题