ExtJs label text change - extjs

In ExtJs how to change label text dynamically
i.e
iam using like this
LabelError.innerText = "New password is required.";
LabelError.style.color = "red";
but its work only in ie and chrome but not in firefox
so how to change label text dynamically in all browsers

As you can see in the label class docs, the right way to do it is to call the function:
LabelError.setText('<span style="color:red">New password is required.</span>', false);
The false argument will prevent the html tags from being mangled by the function. Anyway, you can try to experiment with it.

Related

How to get WebDriver using Python to delete an existing value in the table of a confluence page?

Here's what the HTML code looks like for a confluence page:
tbody
tr
td
some text here
tr
td some text here
tr
td
<span>some text here</span>
If I click on a element and then do a send_keys("XYZ") then all that goes into the middle of the existing text. For example, it can result in any of the following:
soXYZme text here
some tXYZext here
soXYZme text hXYZere
I've also tried double-clicking on the element but that doesn't work properly either. That deletes some part of the existing text only.
How do I clear the existing value in the td element knowing that there's no "input" tag anywhere here. Hence, I cannot use WebDriver's clear() method.
Edit: Please note that sometimes the cells will have a blank value too.
I was editing confluence cells using ActionChains. And ActionChains, for some reason doesn't provide the clear() method.
However, I was able to solve this problem by directly calling the webdriver instance's clear function. So my code looks something like this for confluence:
actions = ActionChains(driver)
#ACTIONCHAINS DOES NOT HAVE A CLEAR FUNCTION
driver.find_element_by_xpath("(//td[contains(#class, 'confluenceTd')])[{0}]".format(i) ).clear()
actions.move_to_element(driver.find_element_by_xpath("(//td[contains(#class, 'confluenceTd')])[{0}]".format(i)))
actions.double_click()
actions.send_keys("SOME DATA")
actions.perform()

How to make quill editor required?

How to make the quill editor field required? The editor gets rendered into a div, but it isn't clear if there is a way to make the field/editor required when the form submits.
As you wrote, Quill works with a div and not with a form element so it can't help you with form validation.
You'll need to check manually if the editor's content is empty, prevent the user from submitting the form and show a message that this field is required.
You can copy quill contents to a hidden input element before submitting the form as shown in this example.
A custom form control is also a good way to go. You can try to workaround with Quill's event handler and getting the value of the form.
Then a custom form validator is also possible.
Check : https://blog.thoughtram.io/angular/2016/07/27/custom-form-controls-in-angular-2.html
I've been trying to work around exactly this problem too today, using Python for back-end and a hidden form-field (name='editor') to get the value from the quill container to the back-end. Ended up with not actually really a validator but working about the same:
if request.form['editor'] == '\"<p><br></p>\"':
flash("You cannot send in empty posts!")
return redirect(CURRENT PAGE)
else:
CODE EXECUTED IF EDITOR IS NOT EMPTY
Not sure what you're doing with the input on the editor or whether you're even using Python for backend but I hope this helps. "<p><br></p>" is what the console told me the standard input on empty submission was when getting the information out of the editor.
Good luck!
const yourText = '<div><br></div>';
const htmlTagsToRemove = ['<div>', '</div>', '<br>'];
function removeHtmlTags(data) {
let text = data;
htmlTagsToRemove.forEach(it => {
text = text.replace(it, '');
});
return text;
}
const newText = removeHtmlTags(yourText);
console.log(newText);

'null' is shown in Angular UI Bootstrap's datepicker input field on Internet Explorer 9

I'm using Angular UI Datepicker. It's behavior is correct on all tested browsers except IE9. On IE9 when i choose some date, then open datepicker again and click on "Clear" button(native button coming from the directive) then "null" text is shown in datepicker's input field.
I have found a related question about that issue. The problem is that in IE whenever javascript sets the input value to a variable which is null then the input field is filled up with the text "null". So the solution for IE9 is to do
document.getElementById('some_id').value = someVar || ''
instead of
document.getElementById('some_id').value = someVar;
but that solution is not applicable for my case because the value of input is being set in the code of directive and i don't want to change that code because dependency is coming from bower and can be updated in future.
The only thing i can do is to write an angular watcher for datepicker model value setting it to empty string in case when it's value becomes null or undefined, but i don't like that solution as i need to do that for each and every page where datepicker is used.
Any idea ?

How to catch chrome's form validation popups

I am writing protractor tests for my form validation.
I want to test that an chrome validation popup appears when a required filed is not set in the form.
When a filed is not set i get "Please fill out this field" from chrome.
I want to do something like this :
submitBtn = element(by.id('submitBtn'));
submitBtn.click();
validationMessage = ???
expect((validationMessage ).getText()).toBe('Please fill out this field');
How to get it ?
You don't need to test the internal implementations of Chrome. The Chrome developers would have had tests to cover the hiding and showing of popups.
You test that your form is written correctly by finding the element that the required attribute should be set on, and asserting that it is indeed set.
myInput = element(by.id('myInput'));
expect(myInput.getAttribute('required')).toBeDefined();

TinyMCE: cake php plugin [ cannot submit form ]

I use https://github.com/CakeDC/TinyMCE to download plugin and did follow all the step to integrate on my cakePHP project. so right now, all the textarea was successfully changed to tinyMCE editor
But when click "SUBMIT" to submit my form, page cannot submit and post data. Without loading editor my form can submit and post data.
Is any jquery problem ? please advise me.
thank you.
Bootsrab.php
CakePlugin::load('TinyMCE');
Configure::write('TinyMCE.editorOptions', array('width' => '500px','height'=>'250px' ));
Controller:
public $helpers=array('Html','Form','TinyMCE.TinyMCE');
View:
$this->TinyMCE->editor(array('theme' => 'advanced', 'mode' => 'textareas'));
echo $this->Form->input('user_requirements',array('required'=>true) );
Layout : default
loding js file:
echo $this->Html->script(array('ddsmoothmenu','jquery-1.7.1.min','jquery-ui-1.8.17.custom.min'));
You've set the field to be required, so the problem you are experiencing is probably the browser based form validation.
The problem is that the validation applies before TinyMCE injects the contents into the textarea, and so the validation will always fail as the textarea is empty. This is a very long known "bug" btw:
http://www.tinymce.com/develop/bugtracker_view.php?id=4768
http://www.tinymce.com/develop/bugtracker_view.php?id=5671
In Firefox you might notice a validation bubble that appears "behind" the browser in the bottom left corner of the screen, and in Chrome for example it would throw the following error: "An invalid form control with name='...' is not focusable".
The quick and dirty fix would be to set required to false. In order to keep the required class on the generated container div you would have to set this manually using the div option:
'div' => array('class' => 'input text required')
It's also possible to disable browser validation completely by defining the novalidate attribute on the form:
$this->Form->create('ModelName', array('novalidate' => true));
or using the formnovalidate attribute on the submit button:
$this->Form->submit('Submit', array('formnovalidate' => true));
Theoretically it would also be possible to listen to the invalid event and display custom validation bubbles, but the problem here is that the browser behavior is not consistent, ie in Chrome it's not possible to validate invisible (using display or visibility) fields. Also the content would still be missing in the textarea field.
What seems to work is using opacity to hide the field, that way one could position the textarea under the editor, and the validation bubble would be displayed correctly. However that would also require to inject the editor contents in the textarea manually when pressing Enter and when clicking the submit button (or probably even simpler using proper editor change events). I'll see if I can come up with an example for this later on.
Update: I've implemented a fix/workaround in form of a TinyMCE 4.x plugin, as this was bugging me in some of my own applications too, see https://github.com/ndm2/tinymce-validatable

Resources