0
votes

im trying to loop a text while input text but i got some error when running it

  *** Settings ***
 Library  Selenium2Library          

  *** Variables ***       

${URL}  https://www.ebay.com           
${Browser}  Chrome   
${Searching}  xpath=//input[@id='gh-ac']    
${Name}  book


 *** Test Cases ***    

Test case Register Positive    
  Open Browser    ${URL}  ${Browser}    
  Input Text  ${Searching}  ${Name}    
  FOR  ${Index}  IN   0   100        
  #LOG TO CONSOLE    ${i}    
    Run Keyword If  ${Searching}  ==  'CONTINUE'   Continue For Loop    
  END

Error says Evaluating expression 'xpath=//input[@id='gh-ac']' failed: SyntaxError: invalid syntax (, line 1)

Please Help

1
try: xpath=//*input[@id='gh-ac'] - Krzy
@Krzy: no, that's not the problem. - Bryan Oakley

1 Answers

1
votes

When robot translates your statement to python code in order to evaluate the expression, it looks literally like this to the python interpreter

if xpath=//input[@id='gh-ac']:

That is invalid python syntax, so you get the error.

If you want to use that variable in a conditional statement, the best solution is to use the special syntax where you omit the braces. When you do that, the variable is used as-is rather than being converted to a string before being handed to python.

You also need to have no more than a single space on each side of ==:

Run Keyword If  $Searching == 'CONTINUE'   Continue For Loop 

For more information in this syntax see Evaluating Expressions in the documentation for the built-in library.