1

I am checking if my element exists, it it does then get "@class" attribute if that element. I am not sure How to do this.

Here is my code

${disabled}=|Set Variable|NONE
${elementPresent}| Is Element Present| ${LOCATOR}
Run Keyword If|"${elementPresent}" == "True"|${disabled}=|Get Element Attribute ${LOCATOR}@class

Here it gives me error that "NONE" is not keyword. Can someone help me here.

2
  • 1
    is this literally your code? You don't have enough whitespace surrounding your pipes. Commented Oct 16, 2015 at 10:45
  • no that was not my code, more of a sudo code Commented Nov 2, 2015 at 4:05

2 Answers 2

3

Quick attempt so have a play until I get back online, I think this happens when it's not hitting your check. The below is how I'd clean it up:

${disabled}=    {FALSE}
${elementPresent}| Is Element Present| ${LOCATOR}
${disabled}=    Run Keyword If|${elementPresent}|Get Element Attribute ${LOCATOR}@class

Let me know what happens. I'm guessing elementPresent will contain only true or false?

Ah sorry I just read further, so basically your NONE is screwing things up. I would change the value as above.

Sign up to request clarification or add additional context in comments.

Comments

0

This worked. It was not working due to some error.

${disabled}=|Run Keyword If|"${elementPresent}" == "True"|Get Element Attribute |${LOCATOR}@class

2 Comments

Please accept the answer in that case. Regarding "${elementPresent}" == "True", this is redundant. as I gave in my example you can just do Run Keyword If | ${elementPresent} This essentially means, run if true. Following my example you default it to false instead of having NONE
I believe your error is that you had the target of your assignment (${disabled}) after Run Keyword If. The target must always precede the first keyword on the line. You should accept @schicky's answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.