can Abaqus getByBoundingBox or findAt() be used for odb? - scripting

I like to find a node or an element based on coordinates in odb in order to plot the data at that node or element. I am wondering if it is possible to use getByBoundingBox() or findAt() in odb? If so, how does it work in odb to find the node and element based on coordinates? Thanks

Yes. You can use the getByBoundingSphere(...) on any MeshNodeArray object.
As example, a MeshNodeArray can be accessed through the root structure: odb/rootAssembly/instance/elements

Related

Can we use Condition with axes in XPATH?

Can we use Condition with axes in XPATH?
Trying to check both parent and child in XPath. Example:
//span[text()='Accounts']/parent::a OR child::div
I know this is wrong. But is there any way to check the condition?
I know the situation looks vague. But I am trying to find a logic where I can use both parent and child axes to create an XPath.
The main motive is to inspect an element from UI and create XPath using axes. and automate the process.
When I am trying the above XPath, it throws some error.
Maybe if you use | instead of OR
//span[text()='Accounts']/(parent::a|child::div)

Nested predicates in Xpath

I am trying to access the div node via
//div[#data-full='2018-1-15']
Normally I would just search by Xpath and grab this node. However the nature of the site is that there are a number of nodes with this property, and only one is clickable.
Because of this I have to grab the
//div[#class='dw-cal-slide dw-cal-slide-a']
node first and then step down. I know I'm trying to do something like this:
Step down one node:
//div[#class='dw-cal-slide dw-cal-slide-a']/div/
And then search for child nodes that have a child node of their own with the property
//div[#data-full='2018-1-15'].
Having trouble with the syntax. Any help would be great!
Try
//div[contains(#class, 'dw-cal-slide') and contains(#class, 'dw-cal-slide-a')]//div[#data-full='2018-1-15']
But IMHO it's better (shorter expression) to use CSS selector
div.dw-cal-slide.dw-cal-slide-a div[data-full='2018-1-15']
If you want to locate ancestor and descendant div in two code lines, then you can use (Python example)
ancestor = driver.find_element_by_xpath("//div[contains(#class, 'dw-cal-slide') and contains(#class, 'dw-cal-slide-a')]")
and
descendant = ancestor.find_element_by_xpath(".//div[#data-full='2018-1-15']")
As you said, there are multiple node with same property and only one is clickable. you can click on the node by checking isEnable. other thing you can try with following-sibling or preceding-sibling. example can be found on below stackoverflow link:
How to use XPath preceding-sibling correctly

Cytoscape.js selecting collapsed nodes

I’ trying to build a Petri Net with Cytoscape.js, using Dagre.js layout and compound nodes for representing places witch in turns are subnets.
I’ using Expand-Collapse extension (Dagre layout) , starting with an overall collapsed network. As the net evolve, I need to update data on every node, including children of collapsed nodes witch users may decide to expand or not .
Here is the issue: I’ not able to select nodes inside collapsed ones nor I can test with IsParent() or any other function applying to compound nodes including slector like “node > node”. Any idea ?
Thanks.
You can't change state of elements that aren't in the graph. Modify them after you add them back (.restore()) to the graph instead.

QTP - Checking dynamic pages

I'm trying to check if a value is contained in the innertext of a webelement but I'm having a little problem: frames seem to change at every refresh of the pages.
These are the steps I've recorded:
Browser("SystemPage").Page("SystemP").Frame("dme2_header").Image("Gestione Anagrafiche").Click<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_appl").WebEdit("pdrBean.pdrPod").Set parameter("POD")<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_appl").WebButton("Cerca").Click
Browser("SystemPage").Page("SystemP").Frame("dme2_appl_2").Image("show_files").Click
Browser("SystemPage").Page("SystemP").Frame("dme2_appl_6").Image("Lente").Click
cctype = Browser("SystemPage").Page("SystemP").Frame("dme2_appl_7").WebElement("arrow_down").GetROProperty("innertext")<br>
DataAct = Browser("SystemPage").Page("SystemP").Frame("dme2_appl_7").WebElement("arrow_down_2").GetROProperty("innertext")<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_header").Image("Gestione Anagrafiche").Click
The frames "dme2_appl6" and "dme2_appl7" changes at every refresh of the two pages.
The question is simple: how can I rewrite these two actions to make them universal?
I've tried to do something like:
Set objFrame = Frame("title:=dme2_appl_.")
and then
Browser("SystemPage").Page("SystemP").objFrame.Image("Lente").Click
But QTP gives me an error in return: "property or method not supported by the object"
Please try using the below code
Browser("SystemPage").Page("SystemP").Image("Lente").Click
Avoid using the "Frame" and if you really want to use it, put regex for name property of Frame.
Go to Object Properties--> Click on the Frame object --> Mandatory Properties--> Change name property as
like iFrame_213123123 to i.*
Hope this will solve your problem.
I don't think you can use a frame object that way. When you write Page().Frame() UFT sets the frame's parent in different way than if you first create the Frame.
Think of Frame() as a function that behaves differently when called on a Page or as a free function.
Try:
Browser("SystemPage").Page("SystemP").Frame("title:=dme2_appl_.")

Select an nth matched node from a list of matching nodes

I'm working with selenium to perform some automation and I'm attempting to interact with my webpage using Selenium & CSS selectors.
My question is how do I select the nth matched node returned from a list of all matching nodes?
For example my CSS selector is ".contactName" which returns 2 matching nodes. Using Selenium I want to do something like
selenium.Click("css=.contactName the second match");
Any help is greatly appreciated.
This is what I ended up using in order to select the second input with the class name
selenium.Click("xpath=(//input[#class='contactName'])[2]");
Do these two nodes share the same parent? If so, you can try one of these, depending on where they are under their parent in the DOM and whether there are any other kinds of elements:
selenium.Click("css=.contactName:nth-child(2)");
selenium.Click("css=.contactName + .contactName");
selenium.Click("css=.contactName ~ .contactName");
If these two nodes don't share the same parent, you'll probably have to go with an XPath locator instead of CSS:
selenium.Click("xpath=//*[#class='contactName'][2]");