0

I need to do some changes in below line :

browser.find_element_by_css_selector("[href='/new/ank/abgh/add/']")

Now I have create a string variable lStr and assign href value to it:

lStr="/new/ank/abgh/add/"

Now I want to know how to replace /new/ank/abgh/add/ with variable lStr in above selenium command. I tried like below :

browser.find_element_by_css_selector("[href='{lStr}']")

but it is not working, I am new to python so do know how to do this.

1 Answer 1

2

Try use plus sign to concatenate them.

browser.find_element_by_css_selector("[href='" + lStr + "']")
#browser.find_element_by_css_selector("[href='"+ str(lStr) + "']")
Sign up to request clarification or add additional context in comments.

1 Comment

In below line: browser.find_element_by_css_selector("[href='/new/ank/abgh/add/']")

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.