codeforequity-at / botium-core

The Selenium for Chatbots - Bots Testing Bots
https://www.botium.ai
MIT License
229 stars 64 forks source link

Adding place holders to a part of the string #381

Closed Sid962 closed 5 years ago

Sid962 commented 5 years ago

Can I know how can I add place holders to a part of a string? Because there is a possibility for the portion of that string to change in each test case. So it is not possible to keep place holders to each word.

codeforequity-at commented 5 years ago

an example please

Sid962 notifications@github.com schrieb am Mo., 23. Sep. 2019, 14:46:

Can I know how can I add place holders to a part of a string? Because there is a possibility for the portion of that string to change in each test case. So it is not possible to keep place holders to each word.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/codeforequity-at/botium-core/issues/381?email_source=notifications&email_token=AGIR2TYCTRB5LYD236XYVYLQLC3CJA5CNFSM4IZKLSHKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HNAZAAQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AGIR2T4R6ZB2BUGOSHS2C5DQLC3CJANCNFSM4IZKLSHA .

Sid962 commented 5 years ago

Currently we have a table in which there are many values that keeps changing in each test case. In a particular column the value has more than one word. How can I keep place holders to that column that have more than one word?

codeforequity-at commented 5 years ago

Still not getting it. Can you please post a concrete example what your plan is.

Sid962 commented 5 years ago

image

Suppose this is the bot response and the "Name" column generates random names like shown above. How can I keep place holder in the "Name" column ?

codeforequity-at commented 5 years ago

you mean, the chatbot responds with a table structure, as html ?

Sid962 commented 5 years ago

yes it is

codeforequity-at commented 5 years ago

By default, before doing any matching, Botium will apply some normalization to the returned text, to make it easier to compose the matching rules. Read about it here:

https://botium.atlassian.net/wiki/spaces/BOTIUM/pages/60817419/What+are+the+Advanced+Scripting+Settings+in+Botium+Box

You could do a matching with regular expressions here, by setting the matching mode to "regexp".

As we know that writing full-blown regular expressions is rather complicated, with Botium Box 1.8 we will introduce a matching mode "wildcard" where you can use an asterisk as placeholder, which is feasible for simple matching cases.

How to apply that in your special case, depends on how the HTML response actually looks like. I would guess that after doing the normalization, the text will be something like this:

Sl.No Name Spend amount 1 Bryant Byun James 1000 2 Cortez Jamerson 1500 ...

A regular expression for matching this would be:

Sl\.No Name Spend amount 1 .+ 1000 2 .+ 1500
codeforequity-at commented 5 years ago

With Botium 1.8, the "wildcard" matching mode is now available: https://botium.atlassian.net/wiki/spaces/BOTIUM/pages/360603/Botium+Configuration+-+Capabilities#SCRIPTING_MATCHING_MODE

Sid962 commented 5 years ago

Yes, problem solved, thank you :)