sub FindInHorizontalRegion { print "Inside FindInHorizontalRegion"; my ( $self,$element1,$element2,$duration,$threshold) = @_; my ($xcoord1,$ycoord1, $xcoord2, $ycoord2); my $regex1 = '(.*?)\:(.*?)'; print "Damn the element1 is $element1 \n"; if ( $element1 =~ m/$regex1/g ) { print "Inside wait for image \n"; my $region = $self->WaitForImage( $element1, $duration ); $xcoord1 = $region->getX; $ycoord1 = $region->getY; print "The coordinates of element1 are $xcoord1, $ycoord1 +\n"; } else { print "Inside wait for Text \n"; my $region = $self->WaitForText( $element1, $duration ); $xcoord1 = $region->getX; $ycoord1 = $region->getY; print "The coordinates of element1 are $xcoord1, $ycoord1 \n"; + } if ( $element2 =~ m/$regex1/g ) { my $region = $self->WaitForImage( $element2, $duration ); $xcoord2 = $region->getX; $ycoord2 = $region->getY; print "The coordinates of element2 are $xcoord1, $ycoord1 \n"; } else { my $region = $self->WaitForText( $element2, $duration ); $xcoord2 = $region->getX; $ycoord2 = $region->getY; print "The coordinates of element2 are $xcoord1, $ycoord1 \n"; } my ($x1,$y1,$x2,$y2) = $self->GetHorizontalCoord($xcoord1,$ycoord1 +,$xcoord2,$ycoord2,$threshold); print "The horizontal coordinates are $x1,$y1,$x2,$y2 \n"; print "The element1 is $element1 \n"; if ( $element1 =~ m/$regex1/g ) { print "To check for iImage"; my $region = $self->WaitForImageInROI($element1,$x1,$y1,$x2,$y +2,$duration); return ($region); } else { print "To check for tText"; my $region = $self->WaitForTextInROI($element1,$x1,$y1,$x2,$y2 +,$duration); return ($region); } } sub GetHorizontalCoord { print "Inside GetHorizontalCoord"; my ( $self,$xcoord1,$ycoord1,$xcoord2,$ycoord2,$threshold ) = @_; my $width = $self->GetDeviceProperty('Width'); my $height = $self->GetDeviceProperty('Height'); my $x1 = 0; my $x2 = $width; my $y1 = $ycoord1 - $threshold ; if ($y1<0) { $y1 = 0; } my $y2 = $ycoord2 + $threshold; if ($y2 > $height) { $y2 = $height; } return ($x1,$x2,$y1,$y2); }
The input in the script goes something like this
my $region = $object->FindInHorizontalRegion('SETTINGS:Flight','SETTIN +GS:Tick','1000',10);
I need to pass SETTINGS:Flight to WaitForImageInROI, instead, the if condition is failing and it is invoking WaitForTextInROI. The problem is that in these lines,
my ($x1,$y1,$x2,$y2) = $self->GetHorizontalCoord($xcoord1,$ycoord1,$xc +oord2,$ycoord2,$threshold); print "The horizontal coordinates are $x1,$y1,$x2,$y2 \n"; print "The element1 is $element1 \n"; if ( $element1 =~ m/$regex1/g ) { print "To check for iImage"; my $region = $self->WaitForImageInROI($element1,$x1,$y1,$x2,$y +2,$duration); return ($region); } else { print "To check for tText"; my $region = $self->WaitForTextInROI($element1,$x1,$y1,$x2,$y2 +,$duration); return ($region); }
though element1 is SETTINGS:Flight, the else condition is getting executed. While the same regex works for the previous if conditions, I'm not able to understand why it does not work here.
Thanks.In reply to Regex not working by Perllace
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |