Reputation: 313
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;']"}
Upvotes: 1
Views: 340
Reputation: 577
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()
Upvotes: 0
Reputation: 1928
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!
Upvotes: 1