How to insert a variable inside an xpath?

bambinou

Client
Регистрация
22.08.2011
Сообщения
436
Благодарностей
21
Баллы
18
Hello

I would like to insert a variable in my path but cannot manage to get it to work:
/ html / body / div [104] / div [1] / div [5] / ul / div [1] / li [ [COLOR=rgb(184, 49, 47)][B]1[/B][/COLOR] ] / div [1] / div [6] / button

I would like to insert Convert.ToInt32 ({- Variable.searchFollowButton-}) where the 1 in red shows up.

I tried this but it does not work:
/ html / body / div [104] / div [1] / div [5] / ul / div [1] / li ['Convert.ToInt32 ({- Variable.searchFollowButton-})' ] / div [ 1] / div [6] / button [/ ICODE]

Any idea why please?

Thank you.
 

EtaLasquera

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

bambinou

Client
Регистрация
22.08.2011
Сообщения
436
Благодарностей
21
Баллы
18
oh I see lol, I have spent hours and hours scratching my head on this one :-)
Let me try your link and see if I can get it to work, very useful thanks!
 

bambinou

Client
Регистрация
22.08.2011
Сообщения
436
Благодарностей
21
Баллы
18
So if I am correct, something like this should work:

C#:
string xpath_exp = "/html/body/div[104]/div[1]/div[5]/ul/div[1]/li["+Variables["searchButton"].Value+"]/div[1]/div[6]/button";
string action_ev = "get|innertext";
string set_action = "";
return CommonCode.FindElementAndExecuteAction(instance, xpath_exp, action_ev, set_action);
 
Последнее редактирование:

bambinou

Client
Регистрация
22.08.2011
Сообщения
436
Благодарностей
21
Баллы
18
I have tried, the program won;t even start with the above
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 233
Благодарностей
5 846
Баллы
113

bambinou

Client
Регистрация
22.08.2011
Сообщения
436
Благодарностей
21
Баллы
18
I see, I forgot "project" ...dang...and I did a totally new working code....well next time I will try that, thanks again!
 

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