Pergunta

Estou usando o Selenium Fitnesse Bridge Fixação para escrever testes no Fitnesse for Selenium.É ótimo porque cobre TODOS as funções que o Selenium possui.No entanto, o problema que estou enfrentando é armazenar variáveis ​​como faria no Selenium IDE.

| !- fixtures.SeleniumFixture -!|
| setup | http://www.google.com/ | *chrome /usr/lib/firefox-3.0.5/firefox |
| open | http://www.google.com/ |  |
| storeLocation | here | |
| echo | ${here} |  |

Algo tão simples como isso deve funcionar bem, mas quando salvo o teste recebo um erro, variável indefinida.

| storeLocation | here |  |
| echo | undefined variable: here |  |

Isso simplesmente não faz sentido.Estou definindo a variável na linha antes de repeti-la.Quando executo o teste, recebo:

| storeLocation | here |  |
| echo | undefined variable: here | undefined variable: here |

O autor está fazendo o mesmo tipo de coisa com seus testes.Por que isso não funciona para mim?

Foi útil?

Solução

O problema é que Fitnesse está ficando confuso.Ele pensa que você não está definindo uma variável.

!define variable {variable}
| echo | ${variable} |  |

A maneira de contornar a confusão de Fitnesse é escapar do nome da variável cercando-o com !- -!.

| storeLocation | here | |
| echo | ${!-here-!} |  |

Isso agora ecoará a resposta desejada.

| !- fixtures.SeleniumFixture -!|
| setup | http://www.google.com/ | *chrome /usr/lib/firefox-3.0.5/firefox |
| open | http://www.google.com/ |  |
| storeLocation | here | |
| echo | ${here} | http://www.google.com |
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top