Git Product home page Git Product logo

Comments (3)

gohiljayraj avatar gohiljayraj commented on May 16, 2024

Below code opens the browser, inputs username and password and click submit button on login page. Page redirected to CRM Home page and after that I am getting below exception:
Code
string userName = ConfigurationManager.AppSettings["Uname"].ToString();
string password = ConfigurationManager.AppSettings["Pwd"].ToString();
Uri xrmUri = new Uri(ConfigurationManager.AppSettings["CrmUrl"].ToString());

        xrmBrowser.GoToXrmUri(xrmUri);            
        xrmBrowser.Driver.FindElement(By.Id("UsernameTextBox")).SendKeys(userName);
        xrmBrowser.Driver.FindElement(By.Id("PasswordTextBox")).SendKeys(password);

        xrmBrowser.Driver.ClickWhenAvailable(By.Id("SubmitButton"), new TimeSpan(0, 0, 2));
        xrmBrowser.Driver.WaitForPageToLoad();

Exception

OpenQA.Selenium.StaleElementReferenceException occurred
HResult=0x80131500
Message=Element is no longer valid
Source=WebDriver
StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebElement.get_Location() at Microsoft.Dynamics365.UIAutomation.Browser.InteractiveBrowser.EventDriver_ElementClicked(Object sender, WebElementEventArgs e) at OpenQA.Selenium.Support.Events.EventFiringWebDriver.OnElementClicked(WebElementEventArgs e) at OpenQA.Selenium.Support.Events.EventFiringWebDriver.EventFiringWebElement.Click() at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.<>c__DisplayClass2_0.<ClickWhenAvailable>b__0(IWebDriver d) at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.WaitUntilClickable(IWebDriver driver, By by, TimeSpan timeout, Action1 successCallback, Action`1 failureCallback)
at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.ClickWhenAvailable(IWebDriver driver, By by, TimeSpan timeout)

from easyrepro.

j621z avatar j621z commented on May 16, 2024

@gohiljayraj This issue has been mitigated and will be pushed to GitHub soon.

from easyrepro.

tipsey avatar tipsey commented on May 16, 2024

Having similar issues with On-premise version:
OpenQA.Selenium.StaleElementReferenceException: 'stale element reference: element is not attached to the page document
(Session info: chrome=67.0.3396.87)
(Driver info: chromedriver=2.40.565498

Debug errors here:
public static IWebElement ClickWhenAvailable(this IWebDriver driver, By by, TimeSpan timeout)
{
var element = driver.FindElement(by);

        WaitUntilClickable(driver,
                            by,
                            timeout,
                            d => { element.Click(); },
                            e => { throw new InvalidOperationException($"Unable to click element."); });



        return element;
    }

` [TestClass]
public class CustomLogin
{
string _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToString();
string _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToString();
Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString());

    [TestMethod]
    public void TestCustomLogin()
    {
        using (var xrmBrowser = new XrmBrowser(TestSettings.Options))
        {
            xrmBrowser.GoToXrmUri(_xrmUri);
            xrmBrowser.Driver.WaitForPageToLoad();

            ///Set Username, password and click Submit button
            xrmBrowser.Driver.FindElement(By.Id("ContentPlaceHolder1_UsernameTextBox")).SendKeys(_username);
            xrmBrowser.ThinkTime(1000);
            xrmBrowser.Driver.FindElement(By.Id("ContentPlaceHolder1_PasswordTextBox")).SendKeys(_password);
            xrmBrowser.ThinkTime(1000);

            xrmBrowser.Driver.ClickWhenAvailable(By.Id("ContentPlaceHolder1_SubmitButton")).Click();
            xrmBrowser.Driver.WaitForPageToLoad();

        }
    }`

from easyrepro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.