I encountered an error when using break function in PAF loop tag - ipaf

break attribute is not mentioned in loop tag
How to use break function in loop tag?

You can use break Variable attribute.
Eg:
<activity id="Loop_Tag">
<loop startIndex="0" lastIndex="10" increment="2" counterVar="i" breakVariable="j" desc="LOOP TAG" expResult="Loop from 0 to 10 incrementing by 2" >
<wait time="1000" desc="WAIT TAG" expResult="Application should wait for 1 secs" ></wait>
<if valGroupIds="VerifyBreak" desc="IF TAG for Validation" expResult="j should be true if the condition pass" >
<variable keyName="j" value="true" desc="VARIABLE TAG" expResult="j equals to true" ></variable>
</if>
</loop>
</activity>
<valGroup groupId="VerifyBreak">
<validate variable="i" condition="equals" value="6" passMsg="PASSED --breakVariable" failMsg="FAILED --breakVariable" desc="VALIDATE TAG" expResult="VALIDATE the validation" >
</validate>
</valGroup>

Related

UiPath selector not working in 'Click Button' Activity

I have the version of UiPath Studio Pro 2020.10.6, and I used Chrome.
I can't find the common Selector on two pages:
First case - failed one
Second case - great one
The selectors offered by the tool are the following:
Case 1:
<html app='chrome.exe' title='Sephora X Coach - Palette de fards à paupières Rexy de SEPHORA COLLECTION ≡ SEPHORA' />
<webctrl id='add-to-cart' tag='BUTTON' type='submit' />
Case 2:
<html app='chrome.exe' title='Kit maquillage des yeux de SEPHORA COLLECTION ≡ SEPHORA' />
<webctrl id='add-all-to-cart' tag='BUTTON' type='submit' />
Removing the title tag does not solve the problem.
The use of wild-cards does not work.
I looked via the "Fuzzy Search":https://docs.uipath.com/studio/docs/fuzzy-search-capabilities
I did the test in Python of the script of the page for the first case: https://www.datacamp.com/community/tutorials/fuzzy-string-python
The result is like in the picture above:
But it's not working too for the first case, since I put the level at 0.1
<html app='chrome.exe' title='"+SelectorString+ "' matching:title='fuzzy' fuzzylevel:title='0.3' /><webctrl id='add-all-to-cart' tag='BUTTON' type='submit' />
with
SelectorString = "Sephora X Coach"
I have no more idea, is the fact that in my first case the button is in a form (when looking at the code of the HTML page) and not in the second case?
Thank you in advance for your help.
I find the solution, I change the selector like that:
<html app='chrome.exe' />
<webctrl id='add[-all]*-to-cart' matching:id='regex' tag='BUTTON' type='submit' />

How to validate XML against XSD in PHP

I have tried to validate my XML against XSD by following way.
<?php
$xml= new DOMDocument;
$xml->load(xml path);
if ($xml->schemaValidate(xsd path)) {print "valid.\n";} else {print "invalid.\n";}
?>
It gives me following error
DOMDocument::schemaValidate(): Element '{http://www.w3.org/2001/XMLSchema}attribute': The content is not valid. Expected is (annotation?).
To see the error detail I add the libxml_use_internal_errors(true); in validation code as you can see below.
<?php
libxml_use_internal_errors(true);
$xml= new DOMDocument;
$xml->load(xml path);
if ($xml->schemaValidate(xsd path)) {print "valid.\n";} else {print "invalid.\n";}
?>
After adding this I got following warning
Severity: Warning
Message: DOMDocument::schemaValidate(): Invalid Schema
I validated this xml online against my xsd and it is valid.However, in my php code it gives me error and I google these errors and it says the document could be invalid while I am sure the document is correct as I have validated it online. I am bit new in this so may be there is some mistake I am doing in validation code but unable to see.
Here is XML
<Application xmlns="NextGenMALI-Schema" Type="NewApplication">
<Identifier>1584928194</Identifier>
<SalesChannel SalesChannelType="Broker">
<Identifier>I12345</Identifier>
<CompanyName BusinessName="National Finance and Loans"/>
<PersonName>
<NameTitle Value="Mr"/>
<FirstName>Jonson</FirstName>
<Surname>Jonson</Surname>
</PersonName>
<RelatedEntityRef Type="crm_id">abc#yahoo.com</RelatedEntityRef>
<Email>abc#yahoo.com</Email>
</SalesChannel>
<SalesChannel SalesChannelDescription="BDM">
<Identifier/>
<PersonName>
<Surname/>
</PersonName>
</SalesChannel>
<Comment>Test comments.</Comment>
<PartySegment>
<Party Type="Applicant" PrimaryApplicant="Yes">
<Identifier>4</Identifier>
<Privacy AllowCreditCheck="Yes" AllowDirectMarketing="No" SignatureVerification="No" PointVerificationCompleted="No" ExistingCustomer="Yes" AllowThirdPartyDisclosure="Yes">
<PointVerification DocumentType="DriversLicenceAust" DocumentNumber="12345" NameOnDocument="Josie Ann Test" VersionSighted="Original" VerificationCategory="Primary" Photographic="Yes" NameVerified="Yes" AddressVerified="Yes" SignatureVerified="Yes" DOBVerified="Yes">
<PlaceOfIssue>
<City>NSW</City>
</PlaceOfIssue>
<EndDate>2014-11-28</EndDate>
</PointVerification>
<DocumentsSightedBy LoanWriter="No"/>
</Privacy>
<ResponsibleLend/>
<Person FirstHomeBuyer="Yes" CustomerOfLender="Yes" EmployeeOfLender="Yes" Director="No" PreviousName="Jones" Sex="Female">
<PersonName>
<NameTitle Value="Mr"/>
<FirstName>First Name</FirstName>
<OtherName>Middle Name</OtherName>
<Surname>Surname</Surname>
</PersonName>
<DateOfBirth>1993-02-01</DateOfBirth>
<MaritalStatus Status="Single" OtherDescription=""/>
<Dependent Age="2"/><Dependent Age="4"/>
<MothersMaidenName>Mother Maiden Name</MothersMaidenName>
<Residency PermanentInAustralia="Yes" Status="Citizen">
<Country ISO3166="AU"/>
</Residency>
<ContactDetails>
<AddressDetails Residential="Yes" Mailing="No" PriorAddress="No" PostSettlement="No" HousingStatus="Boarding">
<RelatedEntityRef>45e7815c217b8a</RelatedEntityRef>
<StartAndEndDates><StartDate>2019-04-04</StartDate></StartAndEndDates>
</AddressDetails><AddressDetails Residential="No" Mailing="No" PriorAddress="No" PostSettlement="No" HousingStatus="Caravan">
<RelatedEntityRef>45e7815c217ba4</RelatedEntityRef>
<StartAndEndDates><StartDate>2017-02-02</StartDate><EndDate>2017-02-02</EndDate></StartAndEndDates>
</AddressDetails><AddressDetails Residential="No" Mailing="No" PriorAddress="No" PostSettlement="No" HousingStatus="Renting">
<RelatedEntityRef>45e7815c217bac</RelatedEntityRef>
<StartAndEndDates><StartDate>2015-03-01</StartDate><EndDate>2015-03-01</EndDate></StartAndEndDates>
</AddressDetails>
<Email PreferredContactMethod="Yes">asd#yahoo.com</Email>
</ContactDetails>
<Employment OnProbation="No" PrimaryEmployment="Yes" PriorEmployment="No" Role="1112-11" RoleDescription="General Manager">
<PAYE Type="FullTime">
<RelatedEntityRef Type="RelatedParty">1097796810218</RelatedEntityRef>
</PAYE>
<StartAndEndDates>
<StartDate>2005-01-01</StartDate>
</StartAndEndDates>
<EmploymentIncome>
<ValueItem Value="10000">
<Identifier>IDARAHXC-Income</Identifier>
<Income Type="OtherIncome">
<Period Unit="Monthly">
<StartDate>2013-07-01</StartDate>
<EndDate>2014-06-30</EndDate>
</Period>
</Income>
</ValueItem>
</EmploymentIncome>
</Employment>
</Person>
</Party>
</PartySegment>
<AddressSegment>
<AddressWrapper>
<Identifier>45e7815c217b8a</Identifier>
<Address>
<StreetNo>8</StreetNo><Street Type="Street">Street</Street><City>Melbourne</City><State Name="VIC"/><Postcode>3000</Postcode>
<Country ISO3166="AU"/>
</Address>
</AddressWrapper>
<AddressWrapper>
<Identifier>45e7815c217ba4</Identifier>
<Address>
<StreetNo>4</StreetNo><Street Type="Street">Street</Street><City>Melville</City><State Name="WA"/><Postcode>6153</Postcode>
<Country ISO3166="AU"/>
</Address>
</AddressWrapper>
<AddressWrapper>
<Identifier>45e7815c217bac</Identifier>
<Address>
<StreetNo>7</StreetNo><Street Type="Street">Street</Street><City>Shire of Mornington Peninsula</City><State Name="VIC"/><Postcode>3941</Postcode>
<Country ISO3166="AU"/>
</Address>
</AddressWrapper>
</AddressSegment>
<FinancialSegment NoOtherAssets="No" NoLiabilities="No" NoIncome="No">
<ValueItem Value="41000">
<Identifier>1097796822609</Identifier>
<OwnedByAllApplicants/>
<Asset Class="CurrentSecurity" SecurityType="RegisteredMortgage">
<RealEstate Transaction="Purchasing" PrimarySecurity="Yes" PropertyPrimaryPurpose="OwnerOccupied" ApprovalInPrinciple="No" Status="Established" Holding="Sole">
<Residential WillOwn3UnitsInComplex="No" WillOwn25PercentOfComplex="No" OffThePlan="No" Type="FullyDetachedHouse"/>
<EstimatedValue>41000</EstimatedValue>
<ContractPrice LicencedRealEstateAgentContract="No" ContractPriceAmount="41000"/>
<VisitContact Type="Customer"/>
<Location>
<RelatedEntityRef>1415066564285</RelatedEntityRef>
<Title TitleType="Torrens" TenureType="Freehold"/>
</Location>
</RealEstate>
</Asset>
</ValueItem>
</FinancialSegment>
<RelatedPartySegment>
<RelatedParty RelPartyType="Lender">
<Identifier>1097796817156</Identifier>
<CompanyName BusinessName="AMP"/>
</RelatedParty>
</RelatedPartySegment>
<LoanDetailSegment>
<LoanDetails>
<Identifier>1097796802265</Identifier>
<EstimatedSettlement>2014-11-28</EstimatedSettlement>
<LoanPurpose PrimaryPurpose="OwnerOccupied" OwnerBuilderApplication="No">
<LendingPurposeCode ABSCode="ABS-125" PurposeAmount="0.0" Description="Affinity Fixed Rate, 1 Year (Investment)"/>
</LoanPurpose>
<LoanPortion ProductName="Affinity Fixed Rate, 1 Year (Investment)" ProductCode="AFFR1I" StatementCycle="Monthly" PackageName="">
<Identifier>1097796802265-1</Identifier>
<LoanTerm Units="Years" Type="TotalTerm">30</LoanTerm>
<LoanTerm Units="Years" Type="Variable" PaymentType="PrincipalAndInterest"/>
<AmountRequested Amount="41315" BaseAmount="41315"/>
<PaymentPeriod Payments="0.0">
<Period Unit="Monthly"/>
</PaymentPeriod>
</LoanPortion>
</LoanDetails>
<Representation Self="No">
<NominatedRepresentation>
<RelatedEntityRef>1415066458059</RelatedEntityRef>
</NominatedRepresentation>
</Representation>
</LoanDetailSegment>
<CrossSellSegment Enabled="true"/>
</Application>
<!-- NGPH: 237119.297 -->
Please find XSD here (Word limit exceeds so I had to upload it to share with you)
https://easyupload.io/qifnk1
password: myxsd

expression builder in BPEL

hello i am a newbie in oracle BPEL and also newbie in xpath, constantly i stuck at this if condition
if (strNOREF == null || (strNOREF != null && strNOREF.trim().length() == 0))
return Response.status(HttpStatus.FORBIDDEN.value()).entity("No. Ref is empty").build();
i wonder how do i translate into BPEL expression?
i tried this with this expression
$inputVariable.payload/ns2:strNOREF = "" or ($inputVariable.payload/ns2:strNOREF != "" and string-length($inputVariable.payload/ns2:strNOREF) = 0)
but it end up at else. i want to end up at my error message
Assuming this is Oracle BPEL.
You can easily do conditional logic like below.
<if name="NameYourCondition">
<condition>$inputVariable.payload/ns2:strNOREF = ""</condition>
<assign name="Assignment">
<copy>
<from>$someVar</from>
<to>$someOtherVar</to>
</copy>
</assign>
<else>
<assign name="DoDifferentAssignment">
<copy>
<from>$someOtherVar</from>
<to>$someVar</to>
</copy>
</assign>
</else> </if>

Removing HTML tags in Applescript using delimiters

How can I remove all of these <br /> tags from the following HTML bellow using delimiters, knowing that this is only part of a large HTML file. I would also like to use the delimiters to remove other tags in my html file.
<Education :<br />
<br />
- School-leaving exam type B, Zug<br />
- Basic course HSG<br />
- Business economist FH, HWV St. Gallen (1990)<br />
<br />
Professional development :<br />
<br />
- 1984-97 GESTIO Treuhand- und Verwaltungs AG, Zug (part time)<br />
- 1985-86 Financial administration Canton of St. Gallen<br />
- 1991-94 Gestinor Services AG, Zug<br />
- 1994-97 Revisuisse Price Waterhouse AG, Zug, Taxes and Law<br />
- 1997 Founding of Bohnet & Schlatter Treuhand AG<br />
<br />
Experience :<br />
<br />
- Tax consultation of legal and natural persons<br />
- Preparation of tax statements for legal and natural persons<br />
- Preparation of structural plans and execution of organizational processes<br />
- Management and support on responsibilities in finances and accounting.
Thanks in advance.
Replacing text is basic enough that most everyone has a handler in their library, for example
on run -- example
set theText to "<Education :<br />
<br />
- School-leaving exam type B, Zug<br />..."
replaceTextInString_fromOldItem_toNewItem_(theText, "<br />", "")
end run
to replaceTextInString_fromOldItem_toNewItem_(someText, oldItem, newItem)
(*
replace all occurances of oldItem with newItem
parameters - someText [text]: the text containing the item(s) to change
oldItem [text]: the item to be replaced
newItem [text]: the item to replace with
returns [text]: the text with the item(s) replaced
*)
set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, oldItem}
try
set {pieces, AppleScript's text item delimiters} to {text items of someText, newItem}
set {someText, AppleScript's text item delimiters} to {pieces as text, tempTID}
on error errorMessage number errorNumber -- oops
set AppleScript's text item delimiters to tempTID -- make sure TID's are reset
error errorMessage number errorNumber -- pass on error
end try
return someText
end replaceTextInString_fromOldItem_toNewItem_
Note that in Snow Leopard and Lion, the text delimiters for the items to replace (the oldItem parameter in my example) can be a list of items.

How do I extract text from a web page with <br /> tags using Hpricot?

I'm trying to parse an HTML file using Hpricot and Ruby, but I'm having issues extracting "free floating" text which is not enclosed in tags like <p></p>.
require 'hpricot'
text = <<SOME_TEXT
Testing:<br />
line 1<br />
line 2<br />
line 3<br />
line 4<br />
line 5<br />
<b>Here's some more text</b>
SOME_TEXT
parsed = Hpricot(text)
parsed = parsed.search('//a[#href="http://www.somelink.com/foo/bar.html"]').first.following_siblings
puts parsed
I would expect the result to be
<br />
line 1<br />
line 2<br />
line 3<br />
line 4<br />
line 5<br />
<b>Here's some more text</b>
But I am getting
<br />
<br />
<br />
<br />
<br />
<br />
<b>Here's some more text</b>
How can I make Hpricot return line 1, line 2, etc?
Your first step is to read the following_siblings documentation:
Find sibling elements which follow the current one. Like the other “sibling” methods, this weeds out text and comment nodes.
Then you should use the Hpricot source to generalize how following_siblings works to get something that works like following_siblings but doesn't filter out non-container nodes:
parsed = Hpricot(text)
link = parsed.search('//a[#href="http://www.somelink.com/foo/bar.html"]').first
link_sibs = link.parent.children
what_you_want = link_sibs[link_sibs.index(link) + 1 ... link_sibs.length]
puts what_you_want
That's pretty much following_siblings with parent.children instead of parent.containers. Having access to the source code of the libraries you use is pretty handy and studying it is to be encouraged.
It's been a while since I've used Hpricot but here's some things I remember that might help:
The quick way to get all the text:
irb(main):023:0> print parsed.inner_text
Testing:
line 1
line 2
line 3
line 4
line 5
Here's some more text
The downside to that is you get the text embedded in tags too.
Similarly, we can search for all 'text()' nodes:
irb(main):033:0> puts (parsed / 'text()')
Testing:
line 1
[...]
line 5
So, we can do this:
irb(main):036:0> puts (parsed / 'text()')[2 .. -3]
line 1
line 2
line 3
line 4
line 5
or:
irb(main):037:0> (parsed / 'text()')[2 .. -3]
=> #<Hpricot::Elements["\n line 1", " \n line 2", "\n line 3", "\n line 4", "\n line 5", "\n "]>
or:
irb(main):039:0> (parsed / 'text()')[2 .. -3].map{ |t| t.inner_text.strip }
=> ["line 1", "line 2", "line 3", "line 4", "line 5", ""]
The main idea for grabbing data/text from a web page is look for landmarks you can use to navigate through the page. Often we can grab text from inside a <div> or <p> tag. If a page doesn't give you landmarks you have to use other tricks; Looking for a series of text nodes followed by <br> nodes maybe, or the five lines following an <a> tag with a certain href attribute. That's the fun and challenge of dealing with HTML.
In the back of my mind there's a nagging thought that there is a more elegant way to do this, but this seems to be working. Dig around on the Hpricot Challenge page for variations on themes on digging out content.

Resources