Simple IF check texte presence

  • Автор темы Автор темы Alienerd
  • Дата начала Дата начала

Alienerd

Новичок
Регистрация
22.03.2018
Сообщения
10
Реакции
0
Баллы
1
Hello,

I'm stucked with a very simple problem, I would like to check a presence of innertext in a button.
So I used Get value[innertext] and then a logic IF with this:
{-Variable.Variable0-}==' Victime de son succès '
Where "Victime de son succès " is the returned value, but it doesn't work.
I upload my template.

Thank you in advance for your help !
 

Вложения

  • test.xmlz
    test.xmlz
    33,8 KB · Просмотры: 261
Thank you esouldy but it still doesn't work as expected.
 
try to do it with c# block

if (project.Variables["tmp"].Value.Trim()=="your text") return 1;
throw new Exception("message");
 
Still not working.
I did a C# box and wrote:
if (project.Variables["tmp"].Value.Trim()==" Victime de son succès ") return 1;
throw new Exception("message");
The variable is found because I see it in an alert box that I created with {-Variable.Variable0-} , but C# box still doesn't work (red cross on it)
I upload the template so maybe you can help me.
 

Вложения

  • test.xmlz
    test.xmlz
    30,9 KB · Просмотры: 267
if (project.Variables["tmp"].Value.Trim()=="Victime de son succès")
without spaces in begin and ending of string =)
 
I removed spaces , still not working.
I also noticed that the alert box showing me the variable, shows:
"Victime deson succès" where de the word "de" and "son" are glued together.
That should be so simple to get a simple IF condition where some innertext is found or not in Zennoposter.
I'm just a newbie :)
Did you check my test.xml file ?
 
Since you are using c#, to compare if a string is equals or contains a text presence, you must use
string str = project.Variables["var"].Value;
if (str.Equals("myTxt")){
return "equals";
}
return "not ok";
 
Since you are using c#, to compare if a string is equals or contains a text presence, you must use
string str = project.Variables["var"].Value;
if (str.Equals("myTxt")){
return "equals";
}
return "not ok";

Thank you for your help, but it still doesn't work. Pretty crazy !
I wrote this in a c# box
string str = project.Variables["var"].Value;
if (str.Equals("Victime de son succès")){return "equals";}
return "not ok";
 
You have a variable with name var?
What is value of that variable?
Maybe it have spaces at begin or end...
Consider this:

Код:
Развернуть Свернуть Копировать
string str = project.Variables["var"].Value.Trim().ToUpper();
string b = "Victime de son succès".ToUpper();

if(str.Contains(b)){
return "OK";
}
return "Not";
 
  • Спасибо
Реакции: gudolik
You have a variable with name var?
What is value of that variable?
Maybe it have spaces at begin or end...
I get my variable Variable0 from inertext
the value returned in an alert box is "Victime deson succès" (I still don't know why 2 words are glued)
So correct me if I'm a wrong, do I need to write this:

string str = project.Variables["Variable0"].Value.Trim().ToUpper();
string b = "Victime de son succès".ToUpper();

if(str.Contains(b)){
return "OK";
}
return "Not";

Because I try with your code then I added Variable0, both don't work.
Could you please check my file ?
 
Thank you so much !
Now I would like to undertsand the process if you dare to.
How do I use the return "Got it" and "Not found" in ZP ? Because the c# box goes directly to sucessfull step. I mean I try with another url where "Victime de son succès" is not in the page and the result is also success.
 
Do it (again).
 

Вложения

Thank you, it's sweet to see people helping beginners :ay:
But, the thing is. Check text presence is pretty easy with ZP and I was able to do that before. I'm looking for checking only the innertext not if the text is found on the page.
I would like to only check the box, this is why I used innertext, and was looking for something like > if innertext is "Victime de son succès" do something.
Any idea now ?
 
Thank you, it's sweet to see people helping beginners :ay:
But, the thing is. Check text presence is pretty easy with ZP and I was able to do that before. I'm looking for checking only the innertext not if the text is found on the page.
I would like to only check the box, this is why I used innertext, and was looking for something like > if innertext is "Victime de son succès" do something.
Any idea now ?
www.google.com or
http://zennolab.com/wiki/en:start
 
I found the answer by myself.
For those who will face the same issue, my problem was indeed very simple, and I'm suprised that confimed techy can't see it immediately.
I wrote '{-Variable.Variable0-}'==' Victime de son succès ' but if I observe correctly the innertext there was 2 spaces before and after the words, so the correct value is '{-Variable.Variable0-}'==' (PUT TWO SPACES HEREVictime de son succèsPUT TWO SPACES HERE '
Pretty simple ;-)
Have great programming guys !:bt:
 
Consider use text processing "trim".
 
I found the answer by myself.
For those who will face the same issue, my problem was indeed very simple, and I'm suprised that confimed techy can't see it immediately.
I wrote '{-Variable.Variable0-}'==' Victime de son succès ' but if I observe correctly the innertext there was 2 spaces before and after the words, so the correct value is '{-Variable.Variable0-}'==' (PUT TWO SPACES HEREVictime de son succèsPUT TWO SPACES HERE '
Pretty simple ;-)
Have great programming guys !:bt:

Are the spaces only for that situation?
 

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)