cannot find css element in protractor - protractor

How do I locate the element with the following html, I have 4 Start buttons each in different color. I tried using css by class and is not working. There are no unique ids as well. Pls help
Start

As Ben Mohorc points out, you really need to give us a bit more to go on. But if you are saying there are multiple start buttons, but only one of each color, it ought to look like this. For now I assume all they say is "Start". If that is only part of what they say, use partial buttontext.If it is background color that differs, you may need to adapt that, too.
var coloredButton = element.all(by.buttonText('Start')).filter(function(elem) {
return elem.getCssValue('color').then(function(color) {
return (color == '#00ff00')//fill in the desired color here, in this format
})
});
Then do your stuff on coloredButton.first(), which will be the only one, according to what you are saying.
For more on the format to expect from the color, see http://www.protractortest.org/#/api?view=webdriver.WebElement.prototype.getCssValue

Related

Match tom select and bootstrap color?

I'm just switch from basic bootstrap 5 select to tom select, but I'm not able to match the colors of the buttons.
This is what it looks like, on the left side is the old bootstrap 5 drop, on the right side is tom select. Color for the select is "btn-outline-secondary".
Example image
Any help would be appreciated!
Was expecting the buttons to have the same border and text color
I found that if you remove the "form-select" class from the tom-select element it should render bootstrap css correctly:
document.getElementById("your_tom_element").classList.remove('form-select');
however, this is a fairly dirty solution in case you need something quick.
I would investigate whether this solution solves your problem, and then see whether some of the bootstrap classes collide with the tom-select classes.
Maybe try to provide also a bit more information regarding your block of code that is problematic.

How to highlight first node of GtkTreeView

I would like to highlight the first node of a GtkTreeView and give that node the focus. gtk_tree_view_row_activated () seems appropriate for what I am trying to do, but I couldn't figure out the arguments it takes.
Thanks in advance.
gtk_tree_view_row_activated() actually acts on just one cell. I wonder if you really want to Highlight the row or just select it. I.e. if you want to leave the highlight even if the cursor is on another line.
If that's the case, note that you can define extra fields in the underlying model, for example, if you have 3 fields for your data, you can add field 4 with a color. Then you can tell the renderer to use the color in field 4 (instead of giving the renderer the color immediately).
This example not only changes the background, but also the text color:
http://faq.pygtk.org/index.py?req=show&file=faq13.031.htp
For more sophisticated work, you can even modify the atributes on a cell-per-cell basis:
http://www.pygtk.org/docs/pygtk/class-gtktreeviewcolumn.html#method-gtktreeviewcolumn--set-cell-data-func
Use set_cursor method:
TextView.set_cursor(0,None,False)
0 = Index of the first row

GXT 3 spinnerField validation

I want to validate that user cannot change spinner value manually by typing in text box of spinner.
For example a field sales multiple = x which I fetched from server not fix.
and displays a spinner field with limitation of like bellow
spinner.setMinValue = x
spinner.setIncrement = x
spinner.setValue = x
so user forcefully select a value which is multiple with x. e.g. if x=3 the user have to enter 3,6,9... and so on.
So here my issue is if I type a 2 in spinner field text box. GXT widget accept that value.
Posible solutions:
Is there any predefined properties of spinnerfield that i forget to set it?
Is there any predefined validator for this?
Can I set text box of spinner field read only by css so user cannot focus on text box but still change a value.
If none of above how to achieve manually?
i've searched a bit in the different classes and I don't see either a precise method which would set what you want.
Don't know about one, and even with one, a validator doesn't change the value in the input field, but maybe it's enough for your needs.
You can disable the text input by calling setEditable(boolean) on the spinnerfield (testSpinner.setEditable(false);)
Maybe you could search around the IntegerPropertyEditor, I haven't tried but as long as a new Spinner is like this:
SpinnerField<Integer> testSpinner = new SpinnerField<Integer>(new NumberPropertyEditor.IntegerPropertyEditor());
you can seen that there is another Constructor for IntegerPropertyEditor, which takes a "NumberFormat" param, but there is no NumberFormart() constructor, so I'm not sure about how you create your own one, but that could be an idea (to format numbers in the input to be a multiple of the increment).
The last option would be that Sencha forgot this possibility and that you should report this as a "bug" on the forum ?
Hope to have helped a bit, good luck :).

HTML DOM Drag and Drop

Yes, this may sound like a frequent question, but Google nor stackoverflow are giving me the answer that I want. I did stumble upon a few results on the WWW, but only found HUGE scripts for just this 1 piece of functionality.
The thing is, I remember doing this before, but I don't exactly remember how. I did it within ONE function and by adding event listeners and stuff along those lines.
Basically, I need a pure DOM script to drag and drop HTML elements for a throwback to older web browsers that don't support the new HTML5 standards. Must be down with the even 'onmousedown', and the text/image must be held for at least 1.5 seconds before calling the dragging.
Thoughts and ideas? Help would be greatly appreciated, guys.
I'm also a bit rusty with screen coordinates and stuff. With this code I want the text to follow the cursor EXACTLY. Not be like, 5 pixels "off" if you know what I mean.
What I had before (parameter of moveText is supposed to be an HTMLDivElement and it's innerText):
function moveText(t){
var id=t.id;
var interval=setInterval(function(){
increment=increment+1;
if(increment>=3){
clearInterval(interval);
t.addEventListener("mousemove",function(event){
t.style.position="absolute";
t.style.top=event.screenY+"px";
t.style.left=event.screenX+"px";
});
}
},500);
t.addEventListener("mouseup",function(){
increment=0;
clearInterval(interval);
});
}

Perl/CGI : format several images

Need a bit more help please...
I need to display 24 times :
or
or
(depending on speed/duplex on the port)
But those images have to be displayed in the switch's image :
How to do to get all images well formated ??
To know which color to choose, I wrote a perl script using Net::SNMP to get infos about speed, duplex...
Thanks guys.
Bye
Hm. Actually, I'd be more tempted to take the images and use CSS styles to color them.
For example, if you took one of those and turned the colored areas transparent, you could place them using CSS, and change the background color, either with generated Perl or with JavaScript on the fly.
It gets a little complex, admittedly; you'll have to create 26 styles (one for each switch), placing them appropriately. You'll need two images (right-side up and upside-down). You'd also have
.yellow { background-color: yellow; }
and so on. But then it's just a matter of adding the appropriate class to the appropriate div; no need to load six different image variants (just two), and you gain the ability to adjust the colors to be anything you want with just a change to the CSS, and do so dynamically if you like.
Does that make any sense?
PerlMagick