Simple IF check texte presence

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 !
 

Вложения

  • 33,8 КБ Просмотры: 172

esouldy

Client
Регистрация
28.02.2016
Сообщения
185
Благодарностей
92
Баллы
28
try this
'{-Variable.Variable0-}'==' Victime de son succès '
 

Alienerd

Новичок
Регистрация
22.03.2018
Сообщения
10
Благодарностей
0
Баллы
1
Thank you esouldy but it still doesn't work as expected.
 

esouldy

Client
Регистрация
28.02.2016
Сообщения
185
Благодарностей
92
Баллы
28
try to do it with c# block

if (project.Variables["tmp"].Value.Trim()=="your text") return 1;
throw new Exception("message");
 

Alienerd

Новичок
Регистрация
22.03.2018
Сообщения
10
Благодарностей
0
Баллы
1
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.
 

Вложения

  • 30,9 КБ Просмотры: 171

esouldy

Client
Регистрация
28.02.2016
Сообщения
185
Благодарностей
92
Баллы
28
if (project.Variables["tmp"].Value.Trim()=="Victime de son succès")
without spaces in begin and ending of string =)
 

Alienerd

Новичок
Регистрация
22.03.2018
Сообщения
10
Благодарностей
0
Баллы
1
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 ?
 

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
524
Благодарностей
112
Баллы
43
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";
 

Alienerd

Новичок
Регистрация
22.03.2018
Сообщения
10
Благодарностей
0
Баллы
1
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";
 

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
524
Благодарностей
112
Баллы
43
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

Alienerd

Новичок
Регистрация
22.03.2018
Сообщения
10
Благодарностей
0
Баллы
1
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 ?
 

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
524
Благодарностей
112
Баллы
43
Do it.
 

Вложения

Alienerd

Новичок
Регистрация
22.03.2018
Сообщения
10
Благодарностей
0
Баллы
1
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.
 

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
524
Благодарностей
112
Баллы
43
Do it (again).
 

Вложения

Alienerd

Новичок
Регистрация
22.03.2018
Сообщения
10
Благодарностей
0
Баллы
1
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 ?
 

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
524
Благодарностей
112
Баллы
43
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
 

Alienerd

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

Alienerd

Новичок
Регистрация
22.03.2018
Сообщения
10
Благодарностей
0
Баллы
1
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:
 

EtaLasquera

Client
Регистрация
02.01.2017
Сообщения
524
Благодарностей
112
Баллы
43
Consider use text processing "trim".
 

yomomma

Пользователь
Регистрация
17.02.2013
Сообщения
53
Благодарностей
2
Баллы
8
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?
 

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