Issues on automating MSD365 with selenium - selenium

I tried to automate Dynamics365 using Selenium, but facing a lot of issues like
Used 'Id' as element locator, but it keeps changing on different instances
Element locator 'Name' is not working in all instances
Xpath came with appending 'id', so it is also dynamic
Due to all these i cant able to run the code in IE,but the code is working in Chrome.
Can someone help with the issue?

I recommend you look into using EasyRepro. It is a C# project from MS in Github that is built on top of Selenium and is a framework that lets you focus on writing meaningful tests instead of learning Selenium and the complicated DOM in D365. It allows you refer to the form objects by the schema name. When you download the project, it is loaded with tons of great examples that you can run to test all different forms and you can modify them to meet your needs.
For example, you can test creating a contact using easy code like this:
xrmBrowser.LoginPage.Login(_xrmUri, _username, _password);
xrmBrowser.GuidedHelp.CloseGuidedHelp();
xrmBrowser.ThinkTime(500);
xrmBrowser.Navigation.OpenSubArea("Sales", "Contacts");
xrmBrowser.ThinkTime(1000);
xrmBrowser.Grid.SwitchView("Active Contacts");
xrmBrowser.ThinkTime(2000);
xrmBrowser.CommandBar.ClickCommand("New");
xrmBrowser.ThinkTime(5000);
var fields = new List<Field>
{
new Field() {Id = "firstname", Value = "Test"},
new Field() {Id = "lastname", Value = "Contact"}
};
xrmBrowser.Entity.SetValue(new CompositeControl() { Id = "fullname", Fields = fields});
xrmBrowser.Entity.SetValue("emailaddress1", "test#contoso.com");
xrmBrowser.Entity.SetValue("mobilephone", "555-555-5555");
xrmBrowser.Entity.SetValue("birthdate", DateTime.Parse("11/1/1980"));
xrmBrowser.Entity.SetValue(new OptionSet { Name = "preferredcontactmethodcode", Value = "Email"});
xrmBrowser.CommandBar.ClickCommand("Save");

Related

Microsoft Graph API not returning custom column from list

Working in VB.Net, using the Microsoft.Graph api communicate with sharepoint.
I have a list on a sharepoint site.
Lets say:
List name : ListTestName
Columns: ListColumnTest1, ListColumnTest2, ListColumnTest3
Dim queryFields As List(Of QueryOption) = New List(Of QueryOption) From {New QueryOption("$expand", "fields")}
Dim items As IListItemsCollectionPage = Await GraphClient.Sites(sharepointSessionId).Lists("ListTestName").Items.Request(queryFields).GetAsync()
This is the code I have to grab the list and trying to get all of the fields (columns) but when I look into the Fields in the "Items" variable I do not see any of the fields that I have added to the list. I only see the sharepoint fields such as "title" or "Id"
I really dont understand why this is not working.
Even when I look via the the graph-explorer site (https://developer.microsoft.com/en-us/graph/graph-explorer) using:
GET https://graph.microsoft.com/v1.0/sites/<SiteId's>/lists/ListTestName/items?expand=fields
I do not see my custom columns However if I try and filter directly to one of the columns like this :
GET https://graph.microsoft.com/v1.0/sites/<SiteId's>/lists/ListTestName/items?expand=fields(select=ListColumnTest1)
This does seem to have returned back my custom field.
Thus I tried adding to the query field {New QueryOption("$expand", "fields(select=ListColumnTest1")} this just crashed when I called the request.
Edit: I asked this question slightly wrong and will be posting a second question that is more to what I need. However, below the question is marked correct because their solution is the correct solution for what I asked. :)
Have you try this endpoint?
GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}?expand=columns,items(expand=fields)
I could get the custom columns with this endpoint.
Updated:
IListColumnsCollectionPage columns = graphClient.Sites["b57886ef-vvvv-4d56-ad29-27266638ac3b,b62d1450-vvvv-vvvv-84a3-f6600fd6cc14"].Lists["538191ae-7802-43b5-90ec-c566b4c954b3"].Columns.Request().GetAsync().Result;
I would avoid to create QueryOption. Try to use Expand and Select method.
Example (C#...apologise I'm not familiar with VB but I hope it will easy for you to rewrite it):
await GraphClient.client.Sites[sharepointSessionId].Lists["ListTestName"].Items.Request()
.Expand(x => new
{
ListColumnTest1 = x.Fields.AdditionalData["ListColumnTest1"],
ListColumnTest2 = x.Fields.AdditionalData["ListColumnTest2"]
})
.Select(x => new
{
ListColumnTest1 = x.Fields.AdditionalData["ListColumnTest1"],
ListColumnTest2 = x.Fields.AdditionalData["ListColumnTest2"]
})
.GetAsync();

Define a predecessor when using Rally WSAPI to add user story

I'm working on a .NET application to add user stories to our Rally workspace, and I'd like to set one of the user stories as a predecessor to the next one. I can add the stories just fine, but the predecessor/successor relationship isn't being created. I'm not getting any errors, it's just not creating the predecessor. (I'm using the Rally.RestApi .NET library).
I have the _ref value for the first story, and I've tried setting the "Predecessors" property on the DynamicJsonObject to that.
followUpStory["Predecessors"] = firstStoryRef;
I also tried creating a string array, no luck.
followUpStory["Predecessors"] = new string[] { firstStoryRef };
I kept the code examples to a minimum since the stories are being created fine and this is the only issue, but let me know if sharing more would be helpful.
The easiest way is to use the AddToCollection method. Check out the docs:
http://rallytools.github.io/RallyRestToolkitFor.NET/html/efed9f73-559a-3ef8-5cd7-e3039040c87d.htm
So, something like this:
DynamicJsonObject firstStory = new DynamicJsonObject();
firstStory["_ref"] = firstStoryRef;
List<DynamicJsonObject> predecessors = new List<DynamicJsonObject>() { firstStory};
OperationResult updateResult = restApi.AddToCollection(followUpStoryRef, "Predecessors", predecessors);

some questions about Extjs 4.0.7

I want to implement a dynamic column in grid panel, how can I do it? I used Extjs 4.0.7:
var result = Ext.JSON.decode(response.responseText);
store.model.setFields(result.fields);
grid.reconfigure(store, result.columns);
store.loadRawData(result.data, false);
The method setFields() doesn't exist in version 4.0.7
Try something like :
var store = new Ext.data.Store({fields: result.fields, data: result.data})
grid.reconfigure(store, result.columns})
The fields config on Store has always behaved this way, with the ability to pass in fields instead of a model. http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.AbstractStore-cfg-fields

Query allowed values of an attribute in Rally using javascript

Could someone tell me how to query allowed values of an attribute in Rally using javascript?
Particularly, I want to query all possible states of a Defect
I know that it can be done with REST api
DynamicJsonObject allowedValues = restApi.GetAllowedAttributeValues("defect", "state");
Is there a javascript equivalence?
You can use RallyDataSource from the App SDK (note, this is the original one, not the new ExtJS-based SDK currently in preview). See the Attribute Values example on this page:
http://developer.rallydev.com/help/data-examples
You may wish to try something along the lines of:
queryConfig = {
type: 'Defect',
key : 'defectStates',
attribute: 'State'
};

Add users to UserMulti field type using Client Object Model

I'm bit of a SharePoint noobie so please bear with me.
I need to be able to create a new list item in one our custom list using the client object model. I have been following the example described on the MSDN site and for the most part this has worked.
We have a list that contains several fields including a UserMulti field type. I am having problems adding users to this field. So far I have tried the following but this somehow always seems to default to the system account rather than the user specified in the field.
...
listItem["ProjectMembers"] = "1;#domain\\johndoe";
listItem.Update();
_clientContext.ExecuteQuery();
Do I need to do some type of lookup first? Any help is appreciated. Thanks.
It took a little while but I figured it out in the end. Below are two approaches you can take
Assign a Principal to the list item
var principal = _rootWeb.EnsureUser("domain\\johndoe") as Principal;
listItem["ProjectMembers"] = principal;
listItem.Update();
_clientContext.ExecuteQuery();
Assign an list of FieldUserValue if you need to assign more than one user to the field.
string[] users = { "domain\\johndoe", "domain\\peterpan" };
var projectMembers = users
.Select(loginName => FieldUserValue.FromUser(loginName))
.ToList();
listItem["ProjectMembers"] = projectMembers;
listItem.Update();
_clientContext.ExecuteQuery();
I'm sure there's better ways of doing things and you could combine the two to ensure that the users are valid before adding them to the list, but this is working so far. Hope this help someone else.
Microsoft has a wiki article, "SharePoint: A Complete Guide to Getting and Setting Fields using C#" that can help. http://social.technet.microsoft.com/wiki/contents/articles/21801.sharepoint-a-complete-guide-to-getting-and-setting-fields-using-c.aspx#Set_and_Get_a_Multi-Person_Field
It includes this sample code.
var lotsofpeople = new SPFieldUserValueCollection(web, item["lotsofpeoplefield"].ToString());
var personA = web.EnsureUser("contoso\\fred");
var personAValue = new SPFieldUserValue(web, personA.ID, personA.LoginName);
var personB = web.EnsureUser("contoso\\barnie");
var personBValue = new SPFieldUserValue(web, personB.ID, personB.LoginName);
lotsofpeople.Add(personAValue);
lotsofpeople.Add(personBValue);
item["lotsofpeoplefield"] = lotsofpeople;
item.Update();