Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99018

Unable to either sendkeys to or close a Pop-up upon going to website

$
0
0

When I go to this site: https://www.flipkart.com/

I'm prompted to enter a username and password but I am unable to use the driver to send keys to either input fields and I also can't use the click method on the x button to skip logging in. I tried using By.xpath and By.className to interact with the WebElements but it won't work. Here's my code to show what I've tried.

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.*;

import java.util.List;
import java.util.concurrent.TimeUnit;

class Test{

public static void main(String[] args) {
            System.setProperty("webdriver.chrome.driver","C:\\SeleniumDrivers\\chromedriver.exe");
            WebDriver driver = new ChromeDriver();
            driver.manage().window().maximize();
            driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
            driver.get("https://www.flipkart.com/");

            //I don't think the pop up is a frame. This doesn't work.
            driver.switchTo().frame(1);
            //className of the 'X' button. Doesn't work
            driver.findElement(By.className("_2AkmmA _29YdH8")).click();
            //two xpaths of the 'X' button. Doesn't work
            driver.findElement(By.xpath("//button[@innertext='✕']")).click();
            driver.findElement(By.xpath("/html/body/div[2]/div/div/button")).click();
            //trying to send text to the email field. Both className and xpath doesn't work
            driver.findElement(By.className("_2zrpKA _1dBPDZ")).sendKeys("test");
            driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/div[2]/div/form/div[1]/input")).sendKeys("test1");


        }
    }

Viewing all articles
Browse latest Browse all 99018

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>