Finding element with similar id of 2 fields - text could be random, Selection should be based on text exists or not - selenium

Please see the image for better understanding
My search is by ID (RIN)
ID could be either Legal Name (Corporation client) or Last Name (Individual Client)
Below code works:
driver.findElement(By.xpath("//td[contains(#id,'l_Name')]")).click(); - This one will click on Legal Name (Working)
driver.findElement(By.xpath("//td[contains(#id,'Last_Name')]")).click(); - This works for Last Name if the search ID (RIN) is given for Last Name
driver.findElement(By.xpath("//td[contains(#id,'Name')]")).click(); - This one also works for Legal Name as the first element displayed is Legal Name But not working for Last Name
If I do
String S = driver.findElement(By.xpath("//td[contains(#id,'l_Name')]")).getText();
System.out.println(S);
KAB GIHADO CARTAGE INC. - String is displayed
But I want something like this:
driver.findElement(By.xpath("//td[contains(#id,'Name')]")) --- (#id,'Name')where driver identify Legal name or Last name based on if text exists or not - Text will be random based on the ID (RIN)

Here is the logic that will get the text from the field contains Name in it's ID and contains some text (not empty).
String S = driver.findElement(By.xpath("//td[contains(#id,'Name')][not(.='')]")).getText();
System.out.println(S);

Related

Splunk: How to extract a field containing spaces at end

I try to extract the value of a field that contains spaces. Apparently it is hard to find a regular expression for this case (even the question is if it is possible at all).
Example: 03 Container ID - ALL_ELIGIBLE_STG_RTAIN Offer Set ID
From Above example, we have to get the count Container ID - ALL_ELIGIBLE_STG_RTAIN
I am Expecting like this.
Container ID
Count
ALL_ELIGIBLE_STG_RTAIN
xxxx
Assuming all container IDs are preceded by "Container ID - " then this command will extract them.
| rex "Container ID - (?<ContainerID>\S+)"

Extract a string after certain word Presto SQL

I'm trying to build a Regex Expression to extract a string after a certain string. The full string I have is:
Your full name (TL submitting form): XXX
What is your vendor location?: Phoenix
The work a want to extract is the vendor location, in the case above would be Phoenix.
I'm using the code below:
LTRIM(RTRIM(REGEXP_EXTRACT(description_text, '(What is your vendor location\?\:)(.*?)(?=)'))) AS vendor_location
The results using this code is:
Task ID. Date Vendor location
90836966 2021-05-14. What is your vendor location?:
Thank you
You can use
REGEXP_EXTRACT(description_text, 'What is your vendor location\?:\s*(.+)', 1)
See the regex demo.
The What is your vendor location\?:\s*(.+) regex matches
What is your vendor location\?: - a What is your vendor location?: literal text
\s* - zero or more whitespaces
(.+) - Group 1: any one or more chars other than line break chars as many as possible.
The last 1 argument extracts the Group 1 value as a result of the function.

Confused about example of creating a formal grammar

I'm reading Dick Grune's Parsing Techniques - A Practical Guide and I'm stuck on an example of what a formal grammar is (starting page 22). He starts with this:
0. Name may be replaced by “tom”
Name may be replaced by “dick”
Name may be replaced by “harry”
1. Sentence may be replaced by Name
2. Sentence may be replaced by Sentence, Name
3. “, Name” at the end of a Sentence must be replaced by “and Name”
before Name is replaced by any of its replacements
4. a sentence is finished only when it no longer contains non-terminals
5. we start our replacement procedure with Sentence
Then he re-writes this more formally as follows:
0. Name -> tom
Name -> dick
Name -> harry
1. Sentence -> Name
Sentence -> List End
2. List -> Name
List -> List , Name
3. , Name End -> and Name
4. the start symbol is Sentence
The re-write above (figure 2.2 in the book) introduces "List". I assume List is a non-terminal, but I can't figure out where it comes from or what it means.
Also, unless I mis-read the text, figure 2.2 is supposed to be the same as the first figure, but they don't exactly match. For example, where is rule #2 from the first figure ("Sentence may be replaced by Sentence, Name") in fig. 2.2?
You didn't copy the table properly.
2 must be:
List -> Name
List -> List , Name
List can either be a single name or a list, a comma and a name.
e.g. "dick , tom and harry" is a valid sentence because we construct it the following way:
Sentence (Replace Sentence)
List End (List will be replaced with "List , Name")
List , Name End (Replace List with "List , Name" again)
List , Name , Name End (Now replace List with Name)
Name , Name , Name End (Replace ", Name End" with "and Name")
Name , Name and Name (Replace the Names)
dick , tom and harry
I hope this will answer your second question as well.

split full arabic name into pieces(SQL)

in SQL Server:
i want to split full name like (محمد محمد وائل أبو العز) which is arabic name thats name found in one column, and i want to put first name محمد in column name (FirstName) and second name محمد in column name (SecondName), and third name وائل in column name (ThirdName), and Fourth name أبو العزin column name (FourthName)
put note that fourth name contsist of tow pieces and this problem may found in first or second or third name
what's your openion in this case
when you execute the following statement
SELECT FirstArabicName,
PARSENAME(REPLACE(FirstArabicName,' ','.'),4) 'FName' ,
PARSENAME(REPLACE(FirstArabicName,' ','.'),3) 'SName' ,
PARSENAME(REPLACE(FirstArabicName,' ','.'),2) 'TName' ,
PARSENAME(REPLACE(FirstArabicName,' ','.'),1) 'Sur Name'
FROM gfodatabase2013.dbo.Students
it works well with names that have one word only, but
you still have a problem with names that have two words like "Abd AlRahman"
how we can solve this problem?

Kettle - Text File Unstructured

I have a text file that its structure is not in a single line, it is certain that the lines start with zero (0). Below is the sample:
header : TEXT<br>
header : TEXT<br>
header : TEXT<br>
line 1 : 0TEXT Name Other Field<br>
line 2 : TEXT Other Field Phone<br>
line 3 : 0TEXT Name Other Field<br>
line 4 : TEXT Other Field Phone<br>
line 5 : 0TEXT textexttexttext <br>
line 6 : 0TEXT Name Other Field<br>
line 7 : TEXT Other Field Phone<br>
line 8 : 0TEXT Name Other Field<br>
line 9 : TEXT Other Field Phone<br>
What I want to do is get through a regex evaluation the NAME and the PHONE fields and store this values.
Name, Phone
Name, Phone
The regex part is ok, I already did it.
What I need to know is how to get the values from two different lines and put it in the same register?
I found this forum http://forums.pentaho.com/showthread.php?53288-Reading-multi-line-records-from-text-file-newbie and tried to apply a javascript suggested, but it didn't work for me, maybe I did something wrong..
I really did some simple wrong and fixed it.
js..
var x;
var charInitial = line.toString().charAt(0);
if(charInitial == '0') {
x = line.toString();
}
else{
x += line.toString();
}
With this script I get the rows separated, I want to concatenate them and after apply the regex. I can concatenate all the rows that belong to the group, and with a regex I can drop that ones that are unnecessary.
Thanks
Given that you have those records in multiple rows, you have the following options:
1) Group by: as long as you can identify your rows that belong together via some set of keys, you can use a group by and create two new fields, Name and Phone, obtained by "Concatenate fields separated by" (not the "concatenate fields separated by ,", mind that). If the values are either what you want to keep or null, the concatenation works;
2) De-normalize. Same principle applies, you need a set of keys to identify records that belong together, but you will need both your Name and Phone to be in the same field (e.g, Value) and you need another field with the key (either Name or Phone).
3) Perhaps the best one: Analytic Query: Use "Lag N rows forward and get field" with N=1 and you get the phone number of the next row. After this step you have rows with a Not null name and the next row's phone number; rows with a null name and a null phone number. Filter the rows you want after and you're done.
This is just a generic idea. You have to sort out the details.