Getting a style value for an element using watir - watir

Below is the sample tag
I would need an output for the style attribute which is "padding-left:16px;;"
Tried
#browser.td(:class, "xxxx").attribute_value("style")
and the output I get is "" where as I was expecting "padding-left:16px;;"
Any help is appreciated.

Use the .style method
padding_left = #browser.td(:class, "xxxx").style('padding-left')

Related

Getting the q-item-label text

I have this code using Quasar/VueJS. What I want to do is update the dropdown text label (keyDropDownLabel) based on the selected <q-item-label>.
So in this example below, I want the newLabelGoesHere part to be Key 1/2/3, depending on which was clicked.
<q-btn-dropdown stretch flat :label="keyDropDownLabel">
<q-list>
<q-item v-for="n in 3" :key="`x.${n}`" clickable v-close-popup tabindex="0">
<q-item-section #click="keyDropDownLabel = 'newLabelGoesHere'">
<q-item-label>Key {{ n }}</q-item-label>
<q-item-label caption>1234567890</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
Anyone help please??
Just modify the q-item-section click method like below:
<q-item-section #click="keyDropDownLabel('Key'+n)">

How to assign a colour to a variable in Fore (colorama)

I am trying to make a function that gets an inputted string and returns it with a random colour. (The random colour is defined earlier)
print(Fore.randomColour + inputVariable)
Whenever I try something along those lines, I end up with the error:
AttributeError: 'AnsiFore' object has no attribute 'randomColour'
I have tried using getattr, but I still couldn't get it to work. Any help will be much appreciated. Thanks.
You can make a list with your defined colors and then pick it randomly.
import random
bcolors = ['\033[95m','\033[94m','\033[92m','\033[93m','\033[91m','\033[1m']
print (random.choice(bcolors) + "random color" + '\033[0m')
where '\033[0m' means reset

In Scala.js, modifying svg.Stylable.style

Working with Scala.js, I have created some SVG elements like Text, Line, Rect, and now I am trying to set the style attribute with code like this, where element is of type svg.Stylable:
element.style.fillOpacity = "0.0"
element.style.stroke = "yellow"
element.style.strokeWidth = "2"
I tried different variations of above code, but the desired style does not realize, and when I inspect the element in the Browser, the style attribute is an empty String (""). I am able to set other attributes with no problem (e.g. x, y, width, height).
How do I set the style? Thanks!
For SVG modications in Scala.js I normally use the d3 library (scala.js facade: https://github.com/spaced/scala-js-d3).
Then u can use:
d3.select("#mySvgElement").attr("style", "stroke:yellow; stroke-width:2") // etc.
*Edit: mySvgElement would be the ID of the element i want to change the style for. You can also other different kind of selectors.

Can't select value in combo box using Coded UI Test

WinComboBox comboxBox = new WinComboBox();
comboxBox.SearchProperties[WinComboBox.PropertyNames.Name] = "Server:";
comboxBox.WindowTitles.Add("Server Settings");
comboxBox.SearchProperties[WinComboBox.PropertyNames.TechnologyName] = "Server";
comboxBox.SearchProperties[WinComboBox.PropertyNames.ControlName] = "comboBoxPlatforms";
comboxBox.SelectedItem = "Value3";
I used above code for selecting a value in a combo box using Coded UI test.
But I am getting the error
System.NotSupportedException: GetProperty of "SelectedItem" is not supported on control type: Window
Can anyone tell me what I am doing wrong or show me an alternative solution?
Sometimes i add this : comboxBox.TechnologyName = “MSAA”;
I think WindowTitles is not needed.
Try also
Mouse.click (comboBox) and playback.wait(1000); above comboxBox.SelectedItem = "Value3"; To exclude some common problems. If that solves your issue then you can start refactoring.
Ik hope it helps.
As the exception points out, the UITestControl object you have is of ControlType WINDOW, which is why you are not able to do SetProperty on it.
I will specify parent control also while searching.
WinComboBox comboxBox = new WinComboBox(WinWIndow Parent);
If your control is WinCombobox try:
combobox.SetProperty("SelectedItem", "Value3");
Also If you know the index of the item try:
combobox.SetProperty("SelectedIndex", 3);
Let me know if it resolves your issue

.attr() is not working in vml rendering

I am working in both IE8(vml) and IE9(svg). To retrieve a element fill color I have used the .attr() method as below
var value= $(element).attr("fill");
Its working fine in svg rendering , but in vml the value is NAN.
Is there any other way to get the attr value in vml rendering?
Thanks in advance
In VML the attribute is called fillcolor i.e.
var value = $(element)[0].fillcolor

Resources