There is a rect object in the dom:
<rect class="slv-blank" id="id123" height="8.8" stroke-width="1px" width="18.8" x="59.2" y="37.5"></rect>
I am trying to search it with following code:
WebDriverWait(driver, 1).until(ec.presence_of_element_located(("xpath", '//rect[@id="id123"]'))).click()
This does not work.
But the following does:
WebDriverWait(driver, 1).until(ec.presence_of_element_located(("xpath", '//*[name()="rect"][@id="id123"]'))).click()
Any clues on why the first one does not work?
Use
Action
class orJavaScript
Executor.OR
<rect>
The
<rect>
element is a basic SVG shape that creates rectangles, defined by their corner's position, their width, and their height. The rectangles may have their corners rounded.An Example:
Attributes
The attributes of
<rect>
elements are as follows:x
: This attribute determines the x coordinate of the rect.y
: This attribute determines the y coordinate of the rect.width
: This attribute determines the width of the rect.height
: This attribute determines the height of the rect.rx
: This attribute determines the horizontal corner radius of the rect.ry
: This attribute determines the vertical corner radius of the rect.pathLength
: This attribute lets specify the total length for the path, in user units.This usecase
As the
<rect>
element is a SVG element so to locate such elements you have to explicitly specify the SVG namespace when accessing the elements using xpath as follows:For
<svg>
elements:For
<g>
elements:For
<rect>
elements:References
You can find a couple of relevant detailed discussions in