1

I want to give Click the button based on style and class name,because in my case there is no unique class name and id.

My html code is

<a class="x-btn x-unselectable rp-important-btn rp-btn-shadow x-box-item x-toolbar-item x-btn-default-small x-noicon x-btn-noicon x-btn-default-small-noicon" 
style="height: 24px; right: auto; top: 5px; margin: 0px; left: 118px;" hidefocus="on" unselectable="on" tabindex="0">

And i have tried

 save_class=driver.find_element_by_xpath("//a[@class='x-btn x-unselectable rp-important-btn rp-btn-shadow x-box-item x-toolbar-item x-btn-default-small x-noicon x-btn-noicon x-btn-default-small-noicon' 
 and style='height: 24px; right: auto; top: 5px; margin: 0px; left: 118px;']")

I am getting following error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//a[@class='x-btn x-unselectable rp-important-btn rp-btn-shadow x-box-item x-toolbar-item x-btn-default-small x-noicon x-btn-noicon x-btn-default-small-noicon' and style='height: 24px; right: auto; top: 5px; margin: 0px; left: 118px;']"}

2 Answers 2

1

You have forgot @style in your xpath

save_class=driver.find_element_by_xpath("//a[@class='x-btn x-unselectable rp-important-btn rp-btn-shadow x-box-item x-toolbar-item x-btn-default-small x-noicon x-btn-noicon x-btn-default-small-noicon' and @style='height: 24px; right: auto; top: 5px; margin: 0px; left: 118px;']")

Try this!

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

Comments

0

Hi to choose with two match attribute and click the button use:

driver.find_element_by_xpath('//a[@class="x-btn x-unselectable rp-important-btn rp-btn-shadow x-box-item x-toolbar-item x-btn-default-small x-noicon x-btn-noicon x-btn-default-small-noicon" and @style="height: 24px; right: auto; top: 5px; margin: 0px; left: 118px;"').click()

1 Comment

My case class is not a unique one.and i want to check style also

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.