Comments (3)
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, Action
1 successCallback, Action`1 failureCallback)
at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.ClickWhenAvailable(IWebDriver driver, By by, TimeSpan timeout)
from easyrepro.
@gohiljayraj This issue has been mitigated and will be pushed to GitHub soon.
from easyrepro.
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)
- [HOW-TO] Add Product to a Quote HOT 1
- regarding Location dialogue in CRM app HOT 15
- [BUG] On a quick create form with a multi select option set, the flyout is not closing causing cover up of additional controls.
- [BUG] EasyRepro tests on Chrome M2 Mac are really slow HOT 1
- Release Wave 2 - 2023 - few dropdown optionsets are not getting identified with data-id when the script ran in New Outlook, where in existing it works fine.
- [HOW-TO] encrypt the password in easyrepro framework. ? HOT 1
- [BUG] <Unable scroll right when column is not visible it's throwing exception>
- Why in my CRM app doesnt work this? xrmApp.Grid.OpenRecord(0); HOT 1
- Release Wave 2 - 2023 - SelectForm() is broken when the script runs with New look
- Unable to Login thru automation in Power App HOT 2
- Compatibility with selenium 4.11 version and CFT
- [BUG] Command Bar not found when header is expanded
- [FEATURE] Get/Retrieve/Search records from timeline
- [BUG] Setting value on Subject field on Case entity (tree-view type)
- [FEATURE] Read the Values from the SLA Timer Section
- [HOW-TO] Run tests on Jenkins
- [HOW-TO] Use with Customer Service Workspace app
- [HOW-TO] <implement read data from excel in easyrepro> HOT 2
- Command xrmApp.Navigation.OpenSubArea("Area", "Sub-Area"); running in Local but failing in pipeline
- How to Close Alert dialogue box of Dynamics crm Opened via Xrm.Navigation.openAlertDialog.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyrepro.