Q:

Problems with XPath in Selenium

I want to find element based on it attributes.
I have already tried searching by all divs, and specify by attributes, and even searching by *. None of this was solution.
Whole element looks like this:
<div class="charc" data-lvl="66" data-world="walios" data-nick="mirek">

This is my search expression:
driver.find_element_by_xpath('//div[@data-world="walios"] and [@data-nick="mirek"]')

I would like to find this element using python with selenium, and be able to click on it.
Actually I am getting the error

SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//div[@data-world="walios"] and [@data-nick="mirek"]' is not a valid XPath expression.

What am I doing wrong?

A:

The error message is correct because your predicate(s) is/are not correct.
Try putting the predicate in one [...] expression: 
driver.find_element_by_xpath('//div[@data-world="walios" and @data-nick="mirek"]')

