خرید بک لینک

Vote count: 0

i need to access a website multiple times a day and want to skip the Log-In page. This is why i want to use Cookies in Java Selenium Chromedriver, for skipping that Log-In after accessing it the first time on a day. Selenium is saving the Cookies correctly, but does not use them and i dont get access on the following page. Can you help me?

This is my Code:

public static void main(String[] args) throws InterruptedException {

    Set<Cookie> cookie = null;
    Iterator<Cookie> itr = null;
    while (true) {

        System.setProperty("webdriver.chrome.driver", "C:\Users\Maxi\Desktop\ChromeDriver.exe");

        driver = new ChromeDriver();
        driver.get("https://www.google.com");

        while (itr != null && itr.hasNext()) {
            driver.manage().addCookie(itr.next());
        }

        driver.navigate().refresh();

        WebDriverWait wait0 = new WebDriverWait(driver, 20);
        if (itr == null) {
            String UserID = "LoginFieldXpath";
            wait0.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(UserID)));

            driver.findElement(By.xpath(UserID)).sendKeys("Useame");

            String PW = "PasswordField Xpath";
            driver.findElement(By.xpath(PW)).sendKeys("Password");

            String LogIn = "LoginButtonXpath";
            driver.findElement(By.xpath(LogIn)).click();

            cookie = driver.manage().getCookies();
            itr = cookie.iterator();    
        }
    }
}

asked 2 mins ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 4 اسفند 1394 ساعت: 23:30

صفحه بندی