O conteúdo das páginas da Web pode ser exibido condicionalmente. Simplificando, o conteúdo da página pode ser alterado dinamicamente com base em diferentes fatores, como geolocalização, função de usuário ou endereço IP. Por exemplo, um modal de assistente de boas-vindas para novos usuários ou uma caixa de texto com conteúdo diferente, dependendo da localidade, pode ser apresentado na página. Para monitorar os elementos do DOM neste caso, você pode personalizar o script de monitoramento gravado com instruções de seleção.

Para criar um script dinâmico que faça algo diferente com base no elemento da Web exibido na página da Web, adicione a instrução if-else ao script na versão de área de trabalho da EveryStep Scripting Tool.

Para a edição de script inline, habilite o recurso Permitir editar script manualmente no menu Configurações Avançadas. Veja também a Ferramenta de Scripting EveryStep: classes, métodos, propriedades, etc.

Exemplo de declaração se-else

Delay ("6sec".ToDuration ());

if (tab0.IsElementPresented("//BUTTON[@ID=\"start\"]/STRONG[normalize-space(text())=\"Edit order\"]")){
tab0.Element ("//BUTTON[@ID=\"start\"]/STRONG[normalize-space(text())=\"Edit order\"]").Click ();
Delay ("3sec".ToDuration ());
if (tab0.IsElementPresented("//INPUT[@ID=\"chkOrder\"]")) tab0.Element ("//INPUT[@ID=\"chkOrder\"]").Click ();
Delay ("1sec".ToDuration ());
if (tab0.IsElementPresented("//BUTTON[@ID=\"btnClose\"]")) tab0.Element ("//BUTTON[@ID=\"btnClose\"]").Click ();
Delay ("1sec".ToDuration ());
if (tab0.IsElementPresented("//BUTTON[@ID=\"end\"]/STRONG[normalize-space(text())=\"End session\"]")) tab0.Element ("//BUTTON[@ID=\"end\"]/STRONG[normalize-space(text())=\"End session\"]").Click ();
Delay ("5sec".ToDuration ());
}
else if (tab0.IsElementPresented("//BUTTON[@ID=\"start\"]/STRONG[normalize-space(text())=\"Start shopping\"]")) {
tab0.Element ("//BUTTON[@ID=\"start\"]/STRONG[normalize-space(text())=\"Start shopping\"]").Click ();
Delay ("1sec".ToDuration ());
tab0.Element ("//INPUT[@ID=\"chkBalance\"]").Click ();
Delay ("1sec".ToDuration ());
tab0.Element ("//BUTTON[@ID=\"btnOk\"]").Click ();
Delay ("1sec".ToDuration ());
if (tab0.IsElementPresented("//INPUT[@ID=\"chkOrder\"]")) tab0.Element ("//INPUT[@ID=\"chkOrder\"]").Click ();
Delay ("1sec".ToDuration ());
if (tab0.IsElementPresented("//BUTTON[@ID=\"btnClose\"]")) tab0.Element ("//BUTTON[@ID=\"btnClose\"]").Click ();
Delay ("1sec".ToDuration ());
if (tab0.IsElementPresented("//BUTTON[@ID=\"end\"]/STRONG[normalize-space(text())=\"End session\"]")) tab0.Element ("//BUTTON[@ID=\"end\"]/STRONG[normalize-space(text())=\"End session\"]").Click ();
}
}