0

I have a new to Selenium and I have an Automation Task from which I have to order an Item from online Site. I successfully reached to the List of Product. Now I have to Click to one of the Product and after click One popup arrives where there is a option of Continue Payment and Proceed to Checkout. Now I cannot find the element in this popup. It throws an exception element-could-not-be-scrolled-into-view. How can I deal with this?

My Code is

class AddToCartPageModel
    {
        public AddToCartPageModel()
        {
            PageFactory.InitElements(PropertiesCollection.driver, this);
        }

        [FindsBy(How = How.XPath, Using = "/html/body/div/div[2]/div/div[3]/div[2]/ul/li[1]/div/div[1]/div/a[1]/img")]
        public IWebElement txtAddToCartItem1 { get; set; }

        [FindsBy(How = How.Name, Using = "Submit")]
        public IWebElement btnAddToCart { get; set; }

        [FindsBy(How = How.CssSelector, Using = ".cross")]
        public IWebElement btnCross { get; set; }



        public void AddItemToCart()
        {
            txtAddToCartItem1.Click();
            PropertiesCollection.driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
            btnAddToCart.Click();
            PropertiesCollection.driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
            btnCross.Click();


        }

    }

In this code .btnCross is the element in the PopUp.

POPUP IMAGE The Image of PopUp

Biraz Dahal
  • 361
  • 1
  • 5
  • 20
  • Probably you should change context first. Something like this driver.switchTo().frame(). Have a look at this question https://stackoverflow.com/questions/14098679/how-to-switch-from-main-window-to-popup-window – Morvader Feb 14 '20 at 09:21
  • I have to pass the element in the frame? How can i find the frame element? I tried using Xpath but it didn't worked. – Biraz Dahal Feb 14 '20 at 09:35
  • Switching to frame didn't help, as there is no frame element. I tried using switching ho ActiveElement and Windows that didn't help me too – Biraz Dahal Feb 14 '20 at 10:04
  • Can you please share the html of the element and parent. – supputuri Feb 14 '20 at 13:37
  • Bu using Thread.Sleep(5000); it worked – Biraz Dahal Feb 15 '20 at 13:42

0 Answers0