如何在运行时增加nth-child值?

时间:2018-11-15 09:50:42

标签: robotframework

供您参考:    我需要在运行时将第n个子级的值增加到'n'个数字。

div.col:nth-child**(1)** > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > combo-box:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div

div.col:nth-child**(2)** > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > combo-box:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div

div.col:nth-child**(3)** > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > combo-box:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div

1 个答案:

答案 0 :(得分:0)

使用For循环实现,我在第n个子项中添加了$ {num}变量

:FOR    ${num}  IN RANGE    0   5
\    Log    div.col:nth-child(${num}) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > combo-box:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div     

您将得到这样的输出

  div.col:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > combo-box:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div
 div.col:nth-child(2) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > combo-box:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div
 div.col:nth-child(3) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > combo-box:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div
 div.col:nth-child(4) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > combo-box:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div