tryingtolearnpython tryingtolearnpython - 1 year ago 105
Python Question

Troubles with XPath Plugin Python

So i am getting the path id('page-content')/x:div[6]/x:div/x:div/x:div/x:a[1]/x:img

How would i go about clicking the img?

I've tried

lol=find_element_by_xpath("//div[@class='emoji-items nano-content']//a[@title=':heart:']/img")

as well as

which i believe should work, but it instead gives me an error

Answer Source

What i did is: select all links elements (a) that contains heart in the title.

I tried to avoid using @title= because sometimes you might have issues due syntax used in the methods for finding the element or in other methods due to special characters like :.

The resulted path was:

//a[contains(@title, 'heart')]

If more elements are found you need to add another element in front of this to restrict the section that is searched in.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download