Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何处理selenium中的登录窗口https://www.flipkart.com/_Selenium_Selenium Webdriver_Webdriver_Webdriverwait - Fatal编程技术网

如何处理selenium中的登录窗口https://www.flipkart.com/

如何处理selenium中的登录窗口https://www.flipkart.com/,selenium,selenium-webdriver,webdriver,webdriverwait,Selenium,Selenium Webdriver,Webdriver,Webdriverwait,打开时https://www.flipkart.com/将打开一个登录窗口。如何在selenium中处理此窗口 System.setProperty("webdriver.gecko.driver", "F:\\Software_Sel\\GekoDriver\\geckodriver-v0.16.1-win64\\geckodriver.exe"); WebDriver wd = new FirefoxDriver(); wd.get("https://www.flipkart.com/")

打开时<代码>https://www.flipkart.com/将打开一个登录窗口。如何在selenium中处理此窗口

System.setProperty("webdriver.gecko.driver", "F:\\Software_Sel\\GekoDriver\\geckodriver-v0.16.1-win64\\geckodriver.exe");
WebDriver wd = new FirefoxDriver();
wd.get("https://www.flipkart.com/")                     
WebElement e1= wd.findElement(By.className("_2AkmmA _29YdH8")); 
e1.click();

我也试过iframe。但是无法处理。请帮助。

您使用的类名_2AkmmA _29YdH8包含两个类。类名定位器只适用于单个类名。相反,您应该使用css。_2AkmmA。_29YdH8

WebElement e1= 
wd.findElement(由.cssSelector(“.2kma.\u 29YdH8”))


希望这有助于u

登录窗口和其中的元素是同一个窗口的一部分,因此您需要引导WebDriverWait使该元素可单击,并且您可以使用以下解决方案:

  • 代码块:

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    
    public class Login_Window_Flipkart {
    
        public static void main(String[] args) {
    
            System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\\\geckodriver.exe");
            WebDriver wd = new FirefoxDriver();
            wd.get("https://www.flipkart.com/");                    
            new WebDriverWait(wd, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//span[contains(.,'Enter Email/Mobile number')]//preceding::input[1]"))).sendKeys("Abhijit@Datta.com");
            wd.findElement(By.xpath("//span[contains(.,'Enter Password')]//preceding::input[1]")).sendKeys("Abhijit@Datta.com");
        }
    }
    
浏览器快照:


这只是一个模式窗口,您可以用与其他窗口相同的方式处理它element@AbhijitDatta请点击“我的答案”旁边的空心复选标记接受答案,该复选标记位于VotedDown箭头下方,因此复选标记变为绿色。