How to get the text of drop down values in squish tool? - python

I have to verify the text of drop down list elements. How can I verify the same using python script in squish tool ?

Naive approach:
Record (then replay) selecting each of the entries. Use exception handling to log accessing individual entries and be able to proceed to test script execution.
More flexible approach:
Recording selecting one of the entries. This gives you script code to make the open the drop down and the object name of the drop down list. Then use object.children() to get all child elements of the drop down list object.
Pseudo example:
drop_down_list = waitForObject(...)
children = object.children(drop_down_list)
test.verify("Entry 1", children[0].text)
(You have to check the properties of the children to see which actual property contains the text or whatever else you want to verify.)

Related

Is there a way in Zapier to convert a python output to separate lines?

I have a Python output in a Zapier output that looks like this:
I want to be able to use this in the body of gmail as separate lines. However, presently, it looks like this when I use that python output as the step. The screenshot below is the email returned after I test.
Is there a filter or a pythonic way to do this within Zapier?
The output would ideally look like this:
https://hectv.sharefile.com/dxxxxxxxfcebd247d09
https://hectv.sharefile.com/dxxxxxxx729cd9494
https://hectv.sharefile.com/d-xxxxxx84622a
Thank you.
William from Zapier answered this for me.
If we're generating a line item array with the code step and we need individual items, you'll want to add a Formatter - Utility - Line Item to Text action.
This action will go just after the Run Python step and should take the Sharefile Output as the input for the formatter. From there, the formatter can break the line item array down into individual text strings that you can assign in the zaps remaining steps. :)
For more information on Formatter check out our article here: https://zapier.com/help/create/format/get-started-with-formatter
For more info on Line Item to Text, check out this article: https://zapier.com/help/create/format/convert-line-items-into-text-strings
Using Line Item to Text, the zap won't care if there are 10 items or a single item, it should still return the same individual items. The main concern there is that the test that is done with Line Item to Text should be a test that include the MAX number of items. This way those items can be assigned in the following steps and used when they're present or ignored when they are not.

Maya Python, Renaming joints: more than one object matches name

Ok, so I get two errors whenever I try to run this script: but before I get ahead of myself: lets get to my objective.
create two joint chains, names are unimportant: but essentially I know that you can use brackets to list and isolate joint chains with matching children names. Instead my script seems to be ignoring the brackets and giving me the error anyways. I've tried every different flag for list relatives: but all that seems to do is change the error to something else.
I know that if this script was properly working it would only work on one joint chain because of the hardcoded names: but the script I'm pulling it from has name prefexes tied to the GUI to avoid hardcoding and allow adaptive naming: I'm only using the hardcoded as an example for this script. My complaint is this script doesn't work on ANY joint chain because I keep getting the error "more than one object matches name."
To run the script,save the following code as a .py in your maya documents script folder, restart your copy of maya, then open a new python tab and run the first three lines of code above import maya.cmds
'''
import exampleScriptTemplate
reload (exampleScriptTemplate)
exampleScriptTemplate.gui()
'''
import maya.cmds as cmds
if cmds.window("buildWin", exists =True):
cmds.deleteUI("buildWin", window = True)
myWindow = cmds.window("buildWin",t='DS_pvFinder',rtf=1,w=100, h=100, toolbox=True)
column = cmds.columnLayout(adj=True)
def gui(*args):
cmds.columnLayout()
cmds.button(w=300,label='build placement curve',c=printMultiple)
cmds.showWindow(myWindow)
def printMultiple(*args):
root = cmds.ls(sl=True)[0]
child = cmds.listRelatives(root,ad=1,f=True,children=True,type='joint')
child.append(root)
child.reverse()
limbJnt = child
print (child)
armroot = []
for j in limbJnt:
wstJnt = cmds.rename(child[3], 'wrist_BIND')
elbJnt = cmds.rename(child[2], 'elbow_BIND')
sdrJnt = cmds.rename(child[1], 'shoulder_BIND')
clvJnt = cmds.rename(child[0], 'clavicle_BIND')
armroot.append(j)
return armroot
I know I'm in the right ballpark. I just need to know how to properly use the brackets to store the list of what i'm selecting instead of searching all of worldspace and breaking.
Thank you for your help
The code you provided is incomplete, no window is opening, so I tried only the printMultiple function which causes a Error: No object matches name in my case.
Your code cannot work like this since you mix hardcoded names with a loop which does nothing. I suppose your main problem is the order of your renamings. The child array contains absolute names like:
[u'joint1', u'|joint1|joint2', u'|joint1|joint2|joint3']
If you now rename child[0] to 'clavicle_BIND', all the remaining elements in the list become invalid because their real names in the scene now look like this:
[u'clavicle_BIND', u'|clavicle_BIND|joint2', u'|clavicle_BIND|joint2|joint3']
What results in an error at the second rename line. Inverting the order sovles this problem, first rename the leaf node, then the ones above.

XML writing- new file

I am using Python to pick a specific set of values from my XML:
children = root[2].getchildren()
for child in children:
ET.dump(child)
Once I use this I get a print of exactly what I need from my XML. I can also change the root number to access different data. I want to export this value as a new separate xml, however when I use :
tree.write('new.xml')
It exports the entire XML, as before. It is not just the value I specified above, value I selected.

wxWidgets Python save checkbox and other elements values in a text

How to save (and restore) the values of the graphical elements of the wxWidgets in Python?
I want some more friendly way, maybe using a for to scrape all the elements and save the current value in a txt when I close the window and restore when I load the app. I do not want to typing 2 line of code (save and restore) to each new element that I add.
#Igor, thanks by the tip of use config_base. I created this code based on:
configHandle = wx.Config(CONFIG_FILE)
# Sweep all elements in `self()` to find the grafical ones
# instance of the wxPython and salve the specific configuration.
for wxElement_name, wxElement_handle in self.__dict__.items():
# Each wxPython object have a specific parameter value
# to be saved and restored in the software initialization.
if isinstance(wxElement_handle, wx._core.TextCtrl):
configHandle.Write(wxElement_name, wxElement_handle.GetValue() )
elif isinstance(wxElement_handle, wx._core.CheckBox):
configHandle.Write(wxElement_name, ('True' if wxElement_handle.GetValue() else 'False') )
elif isinstance(wxElement_handle, wx._core.SpinCtrl):
configHandle.Write(wxElement_name, str(wxElement_handle.GetValue()) )
.
.
.
To restore I use the reverse logic of this code.

Conditional Selecting of child elements in pdfquery

I am using pdfquery to extract data from PDF.
My pdf tree xml looks like following:
<LTTextLineHorizontal>
<LTTextBoxHorizontal>Address</LTTextBoxHorizontal>
</LTTextLineHorizontal>
<LTTextBoxHorizontal>
<LTTextBoxHorizontal>
First-Name
</LTTextBoxHorizontal>
<LTTextBoxHorizontal>
Last-Name
</LTTextBoxHorizontal>
</LTTextBoxHorizontal>
The idea is to make a string that is Address First-Name Last-Name
The need then arises to select child elements depending on their existence, i am at a loss on how to do it.
You'll want to use .extract with the with_parents keyword in order to extract the children. The documentation gives a decent example
pdf.extract([
('with_parent','LTPage[page_index="1"]'),
('last_name', ':in_bbox("315,680,395,700")')
])
In this case, you're simply limiting the search to page 1 of the document. However, you can also pass in the result of previous selections with the with_parent keyword.
For example, if, in your example, Address had children (street, city, zipcode), you could first find the address section, store the element as a variable and then us .extract to pull out the children. How you store and structure the resulting data will depend on your ultimate needs.
address = pdf.pdfquery('LTTextBoxHorizontal:contains("Address")')
pdf.extract([
('with_parent', address),
(..., ...)])
In many cases, the children are not necessarily nested within the xml tree and you need to resort to bbox based approach. What I do in that case is construct a bbox using the "parent" as the top boundary and the next known non-child as the bottom boundary and then pass that in to .extract. Just remember that bboxes are constructed with the bottom-left, top-right coordinates.

Categories

Resources