Value of text field in protractor- undefined - protractor

I am not able to get value of label (as value is not editable and return by API).
I am using getText, but out put is always undefined. The value of this field is 2222.
using below
var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
activatedid.getText()
.then(function(text) {
console.log(this.text);

Remove this. before text, so you have
var activatedid = element(By.xpath("/html/body/app-root/mat-toolbar/div[3]/div[3]"));
activatedid.getText()
.then(function(text) {
console.log(text);
})

Related

MailKit HtmlBody Always Null

I"m trying to get the html from an email retrieved in Gmail. No issues getting the emails however when I attempt to get the HtmlBody it is always null. HTML is present according to the bodyparts.
using (var imap = new ImapClient())
{
imap.Connect("imap.gmail.com", 993);
imap.Authenticate(Login, PW);
var inbox = imap.Inbox;
inbox.Open(FolderAccess.ReadWrite);
string body = "";
if (html)
{
body = inbox.GetMessage(messageID).HtmlBody;
} else
{
body = inbox.GetMessage(messageID).TextBody;
}
imap.Disconnect(true);
return body;
}
I can see from the bodyparts that html is present and if I use this linq I'm able to get the encoded html.
var msg = inbox.GetMessage(messageID).BodyParts.OfType<MimePart>().First(x => x.ContentType.MimeType == "text/html");
Using this I can see there is a Text property but I'm not able to retrieve it. Can anyone assist in getting the unmodified html from Mailkit?
If you change your LINQ statement to:
var msg = inbox.GetMessage(messageID).BodyParts.OfType<TextPart>().First(x => x.ContentType.MimeType == "text/html");
... you'll be able to access the .Text property.
The other option is to cast the msg variable to a TextPart.
The reason you can't access the .Text property in your current code is that this property only exists on the TextPart subclass of MimePart (which is more abstract).

Dart find string value in a list using contains

I have a list of numbers like below -
List contacts = [14169877890, 17781231234, 14161231234];
Now I want to find if one of the above list element would contain the below string value -
String value = '4169877890';
I have used list.any to do the search, but the below print statement inside the if condition is not printing anything.
if (contacts.any((e) => e.contains(value))) {
print(contacts[0]);
}
I am expecting it to print out the first element of the contacts list as it partially contains the string value.
What is it I am doing wrong here?
contacts isn't a List<String>, so your any search can't be true, you need turn element of contracts to string to able to use contains.
void main() {
var contacts = [14169877890, 17781231234, 14161231234];
print(contacts.runtimeType);
var value = '4169877890';
print(value.runtimeType);
var haveAnyValid = contacts.any((element) {
return "$element".contains(value);
});
print(haveAnyValid);
// result
// JSArray<int>
// String
// true
}
Not sure if contacts is an integer and value is a string on purpose or mistake, but this works in dart pad if you convert it to string:
if (contacts.any((e) => e.toString().contains(value))) {
print(contacts[0]);
}
DartPad Link.

Dynamically set form field values in React + Redux

My app's store has a store.authState subtree. In this subtree, there are three things, an authToken, an isFetching boolean and, most importantly a fields object. My form contains two fields : username and password.
I have created an action called SET_FORM_FIELD_VALUE which should generate and update each field's state as they are changed by the user.
I would like my SET_FORM_FIELD_VALUE to update the fields object. If a user normally fills in both username and password fields, my store.authState should look like this:
{
authToken: undefined,
isFetching: false,
fields: {
username: "Brachamul",
password: "azerty123"
}
}
However, it seems that my current code actually just overwrites everything and I end up with :
{
field: {
username: "Brachamul"
}
}
The data in the field changes based on what field I last edited. It's either username or password.
Here is my code :
switch (action.type) {
case 'SET_FORM_FIELD_VALUE':
let field = {} // create a "field" object that will represent the current field
field[action.fieldName] = action.fieldValue // give it the name and value of the current field
return { ...state.fields, field }
How can I change it to fix my issue ?
Your return is wrong, it should be something like this
switch (action.type) {
case 'SET_FORM_FIELD_VALUE':
return {
...state,
fields: {
...state.fields,
[action.fieldName] : action.fieldValue
}
}
}
Hope it helps.
i used change() from 'redux-form'
which only re rendered that specific form input, and isued it pretty often.
everytime the user clicked a dropdown menu it suggested values in 2 input fields
i abstracted away the html from the anwser and some other stuff.
import { FieldArray, Field, change, reduxForm } from 'redux-form';
class WizardFormThirdPage extends react.component{
runInject(target,value){
target.value= value; // sets the client html to the value
// change (formName, Fieldname, Value) in the state
this.props.dispatch(change('spray-record', target.name, value))
}
injectFormvalues(){
var tr = div.querySelector(".applicator-equipment");
var name = div.querySelector("select").value;
if(!name.includes("Select Employee")){
// var inputs = tr.querySelectorAll("input");
var employeeDoc= findApplicatorByName(name); // synchronous call to get info
tractor = tr.querySelector("input")
sprayer = tr.querySelectorAll("input")[1];
// here i send off the change attribute
this.runInject(tractor,Number(employeeDoc.default_t))
this.runInject(sprayer,Number(employeeDoc.default_s));
}
}
// you have to connect it get the dispatch event.
export default connect(state => ({
enableReinitialize: true,
}))(reduxForm({
form: "myFormName", // <------ same form name
destroyOnUnmount: false, // <------ preserve form dataLabel
forceUnregisterOnUnmount: true, // <------ unregister fields on unmount
validate,
})(WizardFormThirdPage));

Issues in store-fed dijit/form/Select by setting preselected value in dojo 1.8

There is another issue when I try to set the preselected (or any) value of my store-fed dijit/form/Select widget.
The markup code is:
<div data-dojo-type="dijit/form/Select" jsId="editOptionsDialog_select" id="editOptionsDialog_select"></div>
and the js:
function editOptionsDialog_fetchData(cId, fieldName, vId) {
var store;
var def;
var return_def = new Deferred();
store = new degreeStore();
def = store.getJsonData();
def.then(function(data) {
store.data = data.items;
editOptionsDialog_select.setStore(new ObjectStore({
objectStore : store
}));
editOptionsDialog_select.value = vId;
editOptionsDialog_select.startup();
editOptionsDialog_select.set('value', 5);
console.info(editOptionsDialog_select);
// here, firebug still shows value = 1
return_def.resolve();
});
return return_def;
}
thx in advance
Greetings
Finally found a solution to the problem:
Since the selection-element DOES NOT support numerical indexes, the indexes had to be casted to strings. With that, a editOptionsDialog_select.set('value', vId.toString()) has finally worked!
Be sure to feed your store by casted numerical ids or then textual-keys by default -> (String)id where id is an integer.
Greetings

Word/Office Automation - How to retrieve selected value from a Drop-down form field

I am trying to retrieve the value of all fields in a word document via office automation using c#. The code is shown below however if the field is a drop-down then the value of the range text is always empty even though I know it is populated. If it is a simple text field then I can see the range text. How do I get the selected drop down item? I feel there must be something quite simple that I'm doing wrong...
private void OpenWordDoc(string filename) {
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
Document doc = app.Documents.Open(filename, ReadOnly: true, Visible: false);
foreach (Field f in doc.Fields) {
string bookmarkName = "??";
if (f.Code.Bookmarks.Count > 0) {
bookmarkName = f.Code.Bookmarks[1].Name; // have to start at 1 because it is vb style!
}
Debug.WriteLine(bookmarkName);
Debug.WriteLine(f.Result.Text); // This is empty when it is a drop down field
}
doc.Close();
app.Quit();
}
Aha - If I scan through FormFields instead of Fields then all is good...
foreach (FormField f in doc.FormFields) {
string bookmarkName = "??";
if (ff.Range.Bookmarks.Count > 0) {
bookmarkName = ff.Range.Bookmarks[1].Name; // have to start at 1 because it is vb style!
}
Debug.WriteLine(bookmarkName);
Debug.WriteLine(ff.Result); // This is empty when it is a drop down field
}
Problem solved. Phew.