Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
regular expression
#11
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks a lot for your time. still having problem. pls see attached if that helps you why i am getting the error.


Attached Files
.doc   forum.doc (Size: 80.5 KB / Downloads: 210)
Reply
#12
Solved: 11 Years, 3 Months, 3 Weeks ago
Looks to me like this is getting too complicated. When you were doing the inline descriptive programming, you were not closing the strings and passing each property as a parameter:

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Frame("micclass:=Frame").Link("micclass:=Link,html tag:=a,text:=(Junk)$|Junk[\d\)\(]+").Click

Should be like this:

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Frame("micclass:=Frame").Link("micclass:=Link", "html tag:=a", "text:=(Junk)$|Junk[\d\)\(]+").Click

That being said, I think that the expression is not taking in to account what appears to be a space between the "Junk" and the number. I think the expression can be greatly simplified as well:

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Link("html tag:=A", "text:=Junk( \(\d+\))?").Click

This expression says "click the link that has the text 'Junk' that may or may not be followed by the expression ' \(\d+\)' which says the text '<one space><one left parenthesis><one or more digits><one right parenthesis>'" Hope this helps!
Reply
#13
Solved: 11 Years, 3 Months, 3 Weeks ago
When using multiple descriptors, try the following:

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Frame("micclass:=Frame").Link("micclass:=Link","html tag:=a","text:=(Junk)$|Junk[\d\)\(]+").Click

Note, the quotes are given between each attribute.

Also, in object identification, add other properties name, innertext, outertext, visible as well. Delete the object inbox() added in object repository, and again add it to OR with these properties.

Make sure you check 'regular expression' checkbox in the properties of the object in OR.
Try with the value Inbox ([0-9].*) in Value configuration options of the property in OR, and do not set '\' backslash. Set Regular expression checkbox.
With all this set, try with
Code:
Browser("micclass:=Browser").Page("micclass:=Page").Frame("micclass:=Frame").Link("innertext:=Inbox ([0-9].*)").Click
Reply
#14
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks .

I am still having same problem. Pls see attached.

I had:

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Frame("micclass:=Frame").Link("micclass:=Link","html tag:=a","text:=(Junk)$|Junk[\d\)\(]+").Click


One thing I noticed that Inbox/Junk both has a html tag = A.

I am doing it in hotmail as i said. If you can do the same in hotmail, i dont know why i cant do it.

Thanks.



one improvement. i added one more property.

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Link("micclass:=Link","html tag:=A","abs_y:=267", "text:=Junk( \(\d+\))?").Click

this code works, if Junk folder has any number(ex: Junk(1), Junk(2)), it clicks. But if Junk folder has no number, no parenthesis, then it gives me error. ex: Junk

Pls help. thx.


Attached Files
.doc   forum1.doc (Size: 135 KB / Downloads: 70)
Reply
#15
Solved: 11 Years, 3 Months, 3 Weeks ago
When Junk folder was empty, using object spy, i found Junk text value was : Junk ()

When Junk folder had one email, using object spy, i found Junk text value was : Junk (1)

Just letting you know.

Thanks.
Reply
#16
Solved: 11 Years, 3 Months, 3 Weeks ago
Ah ha! That's the trick then! I thought that when there was nothing in the folder, the parenthesis and digits would both be gone. try:

Code:
Browser("micclass:=Browser").Page("micclass:=Page").Link("html tag:=A", "text:=Junk \(\d*\)").Click

This says: click the link that has the text "Junk (" that may have zero to many digits followed by the text ")". Also, when doing inline descriptive programming, you do not have to call out the micclass property since it is implied by the fact that you are calling the Link() function. We only use it for Browser and Page as dummy properties so that we get back the only Browser with any Page on it (i.e no identification properties).
Reply
#17
Solved: 11 Years, 3 Months, 3 Weeks ago
You are awesome. Now it works. Many thanks.
When you have a chance, can you explain me the following expressions?
"text:=(Junk)$|Junk[\d\)\(]+") //what the dollar and plus sign for?

"text:=Junk( \(\d+\))?") //here what is the question mark meaning?

Also, do you have any messenger/email so i can ask you more questions?Smile
Reply
#18
Solved: 11 Years, 3 Months, 3 Weeks ago
Code:
(Junk)$|Junk[\d\)\(]+
To break this one down, we first start with the pipe operator "|" which means "or". So we'll take the left expression first.
Code:
(Junk)$
"$" means "end of input". So, the left side means: match the text "Junk" with no characters after it.
Code:
Junk[\d\)\(]+
On the right side, you have the brackets "[]" which denotes a character class. Each character inside it is a "legal" match for the character after the text "Junk". The characters included are "\d" which denotes any digit, "\)" which matches the character ")", and "\(" which matches the character "(". You have to escape parenthesis since they are operators in regular expressions. So, add the "+" to the character class, which will match either parenthesis and any digit, and it means match any one of those three characters one or more times. That's why I didn't think that expression was the best way to do it. It would also match something like "Junk)))234(()234(676767)(((((660"

So, (whew!) the expression says: match the text "Junk" with no characters after it OR match the text "Junk" with one or more characters after it that could be a digit, a left parenthesis, or a right parenthesis.

I explained the "Junk( \(\d+\))?" expression in my post, but I guess I wasn't perfectly clear on the question mark. The question mark means that the expression in the parenthesis grouping may or may not be there.
cdesserich Wrote:This expression says "click the link that has the text 'Junk' that may or may not be followed by the expression ' \(\d+\)' which says the text '<one space><one left parenthesis><one or more digits><one right parenthesis>'"

That's where I was confused before, I thought that when the junk folder was empty the link text would simply be "Junk". So the "Junk( \(\d+\))?" expression will match "Junk" or "Junk (<one or more digits>)". We needed an expression that matched "Junk (<zero or more digits>)" which is why "Junk \(\d*)\)" works. The "*" operator means "zero or more".

Please see Ankur's post about this subject, Regular Expressions Regularized, right here on this site! I have this post bookmarked and use it very frequently as a resource when figuring out regular expressions. There are other good tools out there as well. Another one I use is The RegEx Coach which is a program that helps visualize how regular expressions work. It is free, has great documentation, and good tutorials. Good Luck!

P.S. the email link at the bottom of my posts should work fine, but if questions are asked in a public forum like this, then everyone can benefit from the information shared. I am far from being an expert at regular expressions, I struggle with them a lot, like most people.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need Any digit in xpath path using Regular expression Priyam 1 3,495 10-05-2016, 11:05 AM
Last Post: Ankur
  Regular expression to read two words in lowercase, uppercase and with and without spa sarahq49 1 3,361 04-09-2015, 01:56 AM
Last Post: sarahq49
  Regular expression and script optimisation Padmavathy 1 3,830 03-30-2015, 11:46 AM
Last Post: supputuri
  Regular expression in descriptive programming testernc 1 16,576 12-08-2014, 06:38 PM
Last Post: anshika.agarwal
  need a regular expression. anu05446 0 3,123 11-26-2014, 03:00 PM
Last Post: anu05446

Forum Jump:


Users browsing this thread: 1 Guest(s)