0 votes
2 views
in DevOps and Agile by (19.8k points)

My code is unable to locate element on the Nordstrom rack website even though there is no duplicate class name. The element Account (after signing up) does not get recognized.

using NordstromRack.UI_Elements;

using OpenQA.Selenium;

using OpenQA.Selenium.Interactions;

using OpenQA.Selenium.Support.UI;

using System;

using System.Threading;

namespace NordstromRack

{

    class EntryPoint

    {

        static void Main(string[] args)

        {

            String parentHandle = Driver.driver.CurrentWindowHandle; // get the current window handle

            EmailSignUp signup = new EmailSignUp();

            ProfileUpdate profile = new ProfileUpdate();

            Driver.driver.Navigate().GoToUrl("https://www.nordstromrack.com/");

            Driver.driver.Manage().Window.Maximize();

            Thread.Sleep(1000);

            signup.SignUpLink.Click();

            foreach (String winHandle in Driver.driver.WindowHandles)

            {

                Driver.driver.SwitchTo().Window(winHandle);

            }

            //WebDriverWait wait = new WebDriverWait(Driver.driver, TimeSpan.FromSeconds(1000));

            //wait.Until(ExpectedConditions.ElementToBeClickable(signup.EmailInput));

            signup.EmailInput.Click();

            signup.EmailInput.SendKeys(Config.Credentials.Valid.BaseEmail);

            Thread.Sleep(1000);

            signup.Password.Click();

            signup.Password.SendKeys(Config.Credentials.Valid.Password);

            Thread.Sleep(1000);

            signup.Password.Submit();

            //signup.SignOut.Click();

            //WebDriverWait wait = new WebDriverWait(Driver.driver, TimeSpan.FromSeconds(1000));

            //wait.Until(ExpectedConditions.ElementToBeClickable(profile.Account));

            Thread.Sleep(2000);

            Driver.driver.SwitchTo().Window(parentHandle);

            Thread.Sleep(2000);

            profile.Account.Click();**//Unable to locate this element**

            Thread.Sleep(5000);

            //Driver.driver.Quit();

        }

    }

}

Profile.cs class details which has the account element's locator details. What am I doing wrong? Error thrown: Could not find element by: By.CssSelector: secondary-nav__link.secondary-nav__link--account

using OpenQA.Selenium;

using OpenQA.Selenium.Support.PageObjects;

namespace NordstromRack.UI_Elements

{

    public class ProfileUpdate

    {

        public ProfileUpdate()

        {

            PageFactory.InitElements(Driver.driver, this);

        }

        [FindsBy(How = How.CssSelector, Using = "input.form-label__input.form-label__input--password")]

        public IWebElement Profile { get; set; }

        [FindsBy(How = How.CssSelector, Using = "secondary-nav__link.secondary-nav__link--account")]

        public IWebElement Account { get; set; }

    }

}

1 Answer

0 votes
by (63.4k points)

When use Css Sector it is not necessary to give entire class name.You can give tagname.any of the class attribute or .any of the class attribute Instead this

"secondary-nav__link.secondary-nav__link--account"

can you try that as css Selector

WebElement element1=driver.findElement(By.cssSelector("a.secondary-nav__link")); Actions action = new Actions(driver); action.moveToElement(element1).click().build().perform();

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, you need to enroll in Selenium training institute

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...