How to provide AppleScript support to 'make new' element with one of its own elements - makefile

I am using the 'newScriptingObjectOfClass…' method within my application delegate's class in order to accommodate core data. I can 'make' the container element 'level' just fine, however I haven't a clue how to 'make' the element with one of its own elements. In order to make a new 'unit'--an element of 'levels'--I have to refer back at the containing 'level', which is circular logic.
Here's what seems to be the right way to create my new level, however the 'make' command does not provide the term 'element' as a parameter term for 'level' element, 'unit'.
tell application "SpellAnalysis"
make new level with make new element unit
end tell
Here's what my 'sdef' file shows:
level n : Application levels collection
elements
contains units; contained by application.
unit n [inh. level] : Level's unit collection syn unit
elements
contains sections; contained by levels.
Also noteworthy is that my KVC method is never called from the 'newScriptObjectClass…' method when I successfully make a new 'level' (without a contained 'unit'):
- (void)insertObject:(id)entry inLevelObjectsAtIndex:(NSUInteger)index {}

This compiled for me:
tell application "SpellAnalysis"
((make new level with «class») make new element with unit) // syntax 1
((make new level in class) make new unit with element) // syntax 2
end tell
end tell
you'll likely need to tweak it a bit, but that's the general idea for syntax. when i tried your example i got:
'expected “into”, variable name, class name, other parameter name or
property but found command name.'

Related

Trying to Get child node(Switch ) from Parent(LinearLayout) via AndroidFindby(resourceid), Appium

(class=android.widget.LinearLayout,resource-id=settings_language_selection_toggle,index=1 )
(class=android.widget.RelativeLayout,index=0)
(class=android.widget.LinearLayout,resource-id=widget_frame, index=1)
(class=android.widget.Switch,resource-id=switchWidget, index=0)
/////////////
You can have a look at the hierarchical representation of the elements below
Hierarchy Image View:
***I have tried to reach the switch button by writing the below code on appium Android for java, but it did not work
#AndroidFindBy(xpath ="new UiSelector().resourceId(\"com.idscan.mjcs.sample:id/settings_language_selection_toggle\").instance(1).getChildById(new UiSelector().className(\"android.widget.Switch\")
You using UiSelector syntax in XPath strategy. That is why it isn't working. Try this one:
#AndroidFindBy(uiAutomator = "resourceId(\"settings_language_selection_toggle\").childSelector(className(\"android.widget.Switch\"))")
As you can see here, some boilerplate can be omitted, e.g. new UiSelector().resourceId(...) can be simplified to resourceId(...). One more thing: once you found the root element (LinearLayout with the given resourceId), you can find any child element in the hierarchy using .childSelector() method, nesting doesn't matter.

How can we get the value of textbox in QTP?

I am executing the automated test scripts in UFT 12.5 I am new to UFT. Not very familiar with codes.There is an edit box wherein i have to type the value "S05292". Example:
Browser(Browsername").Page("Pagename").WebEdit("ctl00$ConBody$txtPDNumber").Set "S05292"
The problem is my script fails at this step and does not type the value. Can somebody provide me with a solution which is easy to understand. I tried the below two methods
Method (1)
a=Browser().page().webedit(ctl00$ConBody$txtPDNumber).getroproperty("value")
if a=="S05292" then
msgbox ("displayed message is S05292")
else
msgbox ("msg is not S05292")
end if
Method (2)
x = Browser("Browsername").Page("Pagename").Webedit("ctl00$ConBody$txtPDNumber").GetROProperty("value")
msgbox x
The error message that displays is
Cannot identify the object "ctl00$ConBody$txtPDNumber" (of class WebEdit).
Verify that this object's properties match an object currently displayed in your application.
Use the Object Spy to get the properties of that text box at run time and then make sure they match up to the properties of that text box in your object repository that you defined. Perhaps that don't match up or you didn't uniquely identify that text box.
If you don't want to use an object repository then you have to pass it a property at run time to uniquely identify it. Some thing like:
Browser().page().webedit("developer name:=PDNumber").
Instead of a .set you can do a .type to set/type the value into the text box

Ruby cucumber automation suite - parameter received as null while iterating

I inherited a test automation suite and while modifying it I am trying to write a function to test similar links which are present in the same web page but in different divs and the tag ids are dynamic.
I have a function defined below which accepts an HTML element and sends an action to the element
def element_do(html_element, html_element_type, html_element_value, action)
#browser.send(html_element.to_sym,html_element_type.to_sym ,html_element_value).send(action)
end
I have a method defined as somemethod and I am trying to call the method in a particular div using the some_element#{i} as below
def multiple_accounts
#num_accts.each do |i|
p "validating for account #{i}"
#page.element_do(:div,:id,"some_element#{i}",somemethod)
end
The issue I am facing is that on second iteration the action parameter is passed as null instead of the somemethod. I am new to ruby automation and I am not sure what exactly is happening. Any help is appreciated
Additional details - based on the questions
1) #num_accts is an array which is got by scanning the text of the webpage and contains account numbers (eg: [56544, 87990])
2) This forms a part of the id for the divs as in "acct#56544". So I am passing the array elements from num_accts to "acct#{i}" referred as 'some_element'
3) 'Somemethod' is a method defined to click on a particular link in the div and verifies a text to confirm that the link redirects to the correct page. The some method works fine when there is only one div.
It is not evident from the question, but my suspicion is that you try to pass the name of the method (which returns null), but instead you call the method. I think your call should be:
#page.element_do(:div,:id,"some_element#{i}",'somemethod')

HP-UFT object not found in object repository error

Getting the following error while executing script:
WebList object was not found in the Object Repository.
Check the Object Repository to confirm that the object exists or to find the correct name for the object.
Line (1221): "objParent.WebList(vstrObjectName).select vstrValue".
I understand, it shouldn't be as simple as the object isn't available in the repository but in in case- Try to use 'Locate in repository'
It looks like Line (1221) is trying to access a WebList object by name, but the name is stored in a variable; it is not a string literal in the code.
There might be 3 different things going on here.
1) if you were attempting to use Descriptive Programming, then it sounds like the contents of vstrObjectName didn't include the ":=" symbol that would make QTP believe the string is a description... So, QTP thinks the string stored in vstrObjectName must be the name of an object in the Object Repository.
I would like to guess that you were trying to use descriptive programming, since (based on the fact that the parent, and the parameter are also both contained in variables) it looks like you are avoiding using any string literals in that line.
2) If you were attempting to control an object with a name from the Object repository, then either the string contained in vstrObjectName didn't contain a valid object name (that belongs to objParent), or
3) the object refered to by objParent isn't the one you were expecting.
In any of these cases, if it were me, the first thing I would do is add a print statement before line 1221 as:
Print "vstrObjectName:'" & vstrObjectName & "'"
...and run it again. That should show the string that you were referencing. I would guess that the resulting output line is not what you expected.
Another thing to check is to make sure that the action or function that contains that line is executed from within an action that contains that named object in it's OR scope. (i.e. open the action and hit CTRL-R, it shows the combined OR that is visible to that action). If the line is in a function library, and it gets called from an action that doesn't have the object in it's local OR, or an attached shared OR, then you will get the same error. This kind of problem is very easy to cause if you use multiple actions, and the action containing the call to the function that contains your line (line 1221) doesn't actually have that object available to it due to it's OR scope.
To answer the question you asked - how to add object into the OR - you could use several methods - recording, guispy's add to OR button, manually add from the OR screen, etc... but in the end, you need that object in the OR to have a name that matches whatever is in vstrObjectName.
Some potential examples where an object can be selected:
Dynamically change the object based on the name of the object in the object repository:(must exist in the repository)
Dim objectname
objectname = "SAP Work Manager"
msgbox WpfWindow(objectname).Exist
Select an object that does not exist in the Object repository, by its properties:
WpfWindow("text:=SAPWorkManager").Exist
Example page of UFT tips

PageObject with Ruby - set text in a text field only works in the main file

I'm automating a site that has a page with a list of options selected by a radio button. When selecting one of the radios, a text field and a select list are presented.
I created a file (test_contracting.rb) that is the one through which I execute the test (ruby test_contracting.rb) and some other classes to represent my page.
On my class ContractPage, I have the following element declaration:
checkbox(:option_sub_domain, :id => "option_sub_domain")
text_field(:domain, :id => "domain_text")
select_list(:tld, :id => "domain_tld")
I've created in the ContractPage a method that sets the configuration of the domain like this:
def configure_domain(config={})
check_option_sub_domain
domain = config[:domain]
tld = config[:tld]
end
When I call the method configure_domain from the test_contracting.rb, it selects the radio button, but it doesn't fill the field with the values. The params are getting into the method correctly. I've checked it using "puts". Even if I change the params to a general string like "bla" it doesnt work. The annoying point is that if on test_contracting.rb I call the exact same components, it works.
my_page_instance = ContractPage.new(browser)
my_page_instance.domain = "bla"
my_page_instance.tld = ".com"
What I found to work was to in the configure_domain method, implement the following:
domain_element.value = config[:domain]
tld_element.send_keys config[:locaweb_domain]
Then it worked.
The documentation for the PageObjects module that I'm using as reference can be found here: http://rubydoc.info/github/cheezy/page-object/master/PageObject/Accessors#select_list-instance_method
Do you guys have any explation on why the method auto generated by the pageobject to set the value of the object didnt work in this scope/context ?
By the way, a friend tried the same thing with Java and it failed as well.
In ruby all equals methods (methods that end with the = sign) need to have a receiver. Let me show you some code that will demonstrate why. Here is the code that sets a local variable to a value:
domain = "blah"
and here is the code that calls the domain= method:
domain = "blah"
In order for ruby to know that you are calling a method instead of setting a local variable you need to add a receiver. Simply change your method above to this and it will work:
def configure_domain(config={})
check_option_sub_domain
self.domain = config[:domain]
self.tld = config[:tld]
end
I'm pretty new to this world of Selenium and page objects but maybe one of my very recent discoveries might help you.
I found that that assignment methods for the select_list fields only worked for me once I started using "self" in front. This is what I have used to access it within my page object code. e.g., self.my_select_list="my select list value"
Another note - The send_keys workaround you mention is clever and might do the trick for a number of uses, but in my case the select list values are variable and may have several options starting with the same letter.
I hope something in here is useful to you.
UPDATE (Jan 3/12)
On diving further into the actual Ruby code for the page object I discovered that the select_list set is also using send_keys, so in actuality I still have the same limitation here as the one I noted using the send_keys workaround directly. sigh So much to learn, so little time!

Resources