Note that there are some explanatory texts on larger screens.

plurals
  1. POGet the value of a particular css element id from child css element
    primarykey
    data
    text
    <p>I am using <em>Selenium WebDriver</em> wrapped in <em>PHPUnit</em> and <em>Sausage</em> to test clicking a button in a specific row in a table that's laid out similar to:</p> <pre><code>&lt;tr id="dynamically generated 1"&gt; &lt;td class="foo"&gt; &lt;div class="bar"&gt;&lt;/div&gt; &lt;/td&gt; &lt;td class = "mybutton"&gt; &lt;span class = "icon clickable"&gt;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="dynamically generated 2"&gt; &lt;td class="foo"&gt; &lt;div class="baz"&gt;&lt;/div&gt; &lt;/td&gt; &lt;td class = "mybutton"&gt; &lt;span class = "icon clickable"&gt;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>In particular, I want to click a specific element <code>#mybutton &gt; span.icon.clickable</code> whose sibling is <code>.foo</code> with child <code>.baz</code>. The "<em>whose sibling is <code>.foo</code> with child <code>.baz</code></em>" requirement is the only way I can currently identify the correct element, as other rows in the same table have element <code>#mybutton &gt; span.icon.clickable</code>, and the ids for those rows are dynamically generated.</p> <p>At the moment I am using XPath, but as you might expect, performance on <code>FF</code> and <code>IE</code> is horrendous. Is there a method for retrieving the value of <code>tr#id</code> from the element <code>tr#id div.bar</code>? If I can get this, I can use the id to use CSS to find the element I am looking for. I am using PHP, but a solution in any language would be useful. </p> <p>Alternatively, a more straightforward CSS3 solution would work, but after quite a bit of reading, I've all but concluded that using a standard CSS3 selector is not an option for this case. Just in case there is something I'm missing, is there a CSS3 solution for this? I know there is a CSS4 solution, but I need full browser support, so until all the browsers I am testing support CSS4, I'll have to rely on CSS3.</p> <p>Thanks in advance.</p> <p><strong>EDIT:</strong> Until there is better cross-browser support for CSS4, I need to use CSS3</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload