Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selenium find element by title that contains?

I need to find the RSSI (4G Signal Strength) from the output below using selenium.

From what I can see if I first need to find all the elements that contain the title EE000000. then I can see what looks to be a path attribute in the parent div that matches another child div with the same path

For example 0-7262-12686-13379 is named in two divs, in one is the title and in the other is the values I want.

then I need to get title that begins with "4G signal Strenght" to get that value, my end result should be

EE100000 -96
EE100001 -81

and so on...

thus far my path attempt has failed to find the EE100000 values as per the below, which was trying to find an existing EE no, not all EE not

driver.find_element_by_xpath('//*[contains(@title, "EE100205")')
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//*[contains(@title, "EE100205")' is not a valid XPath expression.

ive added the source as an image through

source code sample below:-

  <div class="slick-row  odd" row="1" style="height:29px">
        <row>
            <div class="slick-cell lr c0 treeColumn children00">
                <div class="treeItem deviceItem cell-inner device expanded isnotfavorite remoteprobe isnotpaused" idx="1"
                    level="2" objid="13379" type="device" path="0-7262-12686-13379" template="_Prtg.Core.device.js">
                    <level last="true"></level>
                    <level lastx="false">
                        <level>
                            <toggler></toggler>
                        </level>
                    </level>
                    <div class="indent level2" title="EE100133 RS – NAME&lt;br/&gt;(6 Sensors)&lt;br/&gt;OK">
                        <level class="device">
                            <icon popup="333" style="background-image:url(/icons/devices/vendors_cradlepoint.png)"></icon>
                        </level>
                        <device>
                            <name popup="3333" goto="true">EE100133 - RS NAME </name>
                            <condition></condition>
                            <favorit>
                                <span class="objectisnotfavorite icon-gray ui-icon ui-icon-flag" id="fav-13379" onclick="_Prtg.objectTools.faveObject.call(this,13379,'toggle');return false;"></span>
                            </favorit>
                            <status></status>
                        </device>
                    </div>
                </div>
            </div>
            <div class="slick-cell lr c1 valueColumn children00">
                <div class="sensorItem cell-inner c1 drop device expanded isnotfavorite remoteprobe isnotpaused" idx="1"
                    objid="13379" type="device" path="0-7262-12686-13379" template="_Prtg.Core.sensor.js">
                    <div>
                        <sensor idx="0" objid="13380" type="sensor" class="sensor dragable  isnotpaused isnotfavorite status3"
                            title="Throughput (1,19 kbit/s)">
                            <icon popup="333" goto="true"></icon>
                            <name popup="3333" goto="true">Throughput</name>
                            <value goto="true">1,19 kbit/s</value>
                            <favorit>
                                <span class="objectisnotfavorite icon-gray ui-icon ui-icon-flag" onclick="_Prtg.objectTools.faveObject.call(this,13380,'toggle');return false;"></span>
                            </favorit>
                        </sensor>
                        <sensor idx="1" objid="13381" type="sensor" class="sensor dragable  isnotpaused isnotfavorite status3"
                            title="Uptime (306 d)">
                            <icon popup="333" goto="true"></icon>
                            <name popup="3333" goto="true">Uptime</name>
                            <value goto="true">306 d</value>
                            <favorit>
                                <span class="objectisnotfavorite icon-gray ui-icon ui-icon-flag" onclick="_Prtg.objectTools.faveObject.call(this,13381,'toggle');return false;"></span>
                            </favorit>
                        </sensor>
                        <sensor idx="2" objid="13382" type="sensor" class="sensor dragable  isnotpaused isnotfavorite status3"
                            title="4G Signal strength (-96 #)">
                            <icon popup="333" goto="true"></icon>
                            <name popup="3333" goto="true">4G Signal strength</name>
                            <value goto="true">-96 #</value>
                            <favorit>
                                <span class="objectisnotfavorite icon-gray ui-icon ui-icon-flag" onclick="_Prtg.objectTools.faveObject.call(this,13382,'toggle');return false;"></span>
                            </favorit>
                        </sensor>
                        <sensor idx="3" objid="13383" type="sensor" class="sensor dragable  isnotpaused isnotfavorite status3"
                            title="4G Signal quality (-7 #)">
                            <icon popup="333" goto="true"></icon>
                            <name popup="3333" goto="true">4G Signal quality</name>
                            <value goto="true">-7 #</value>
                            <favorit>
                                <span class="objectisnotfavorite icon-gray ui-icon ui-icon-flag" onclick="_Prtg.objectTools.faveObject.call(this,13383,'toggle');return false;"></span>
                            </favorit>
                        </sensor>
                        <sensor idx="4" objid="13384" type="sensor" class="sensor dragable  isnotpaused isnotfavorite status3"
                            title="3G Signal quality (-6 #)">
                            <icon popup="333" goto="true"></icon>
                            <name popup="3333" goto="true">3G Signal quality</name>
                            <value goto="true">-6 #</value>
                            <favorit>
                                <span class="objectisnotfavorite icon-gray ui-icon ui-icon-flag" onclick="_Prtg.objectTools.faveObject.call(this,13384,'toggle');return false;"></span>
                            </favorit>
                        </sensor>
                        <sensor idx="5" objid="13385" type="sensor" class="sensor dragable  isnotpaused isnotfavorite status3"
                            title="Network Bearer (211 msec)">
                            <icon popup="333" goto="true"></icon>
                            <name popup="3333" goto="true">Network Bearer</name>
                            <value goto="true">211 msec</value>
                            <favorit>
                                <span class="objectisnotfavorite icon-gray ui-icon ui-icon-flag" onclick="_Prtg.objectTools.faveObject.call(this,13385,'toggle');return false;"></span>
                            </favorit>
                        </sensor>
                    </div>
                </div>
            </div>
        </row>
    </div>
    <div class="slick-row  even" row="2" style="height:29px">
        <row>
            <div class="slick-cell lr c0 treeColumn children00">
                <div class="treeItem deviceItem cell-inner device expanded isnotfavorite remoteprobe isnotpaused" idx="2"
                    level="2" objid="14551" type="device" path="0-7262-12686-14551" template="_Prtg.Core.device.js">
                    <level last="true"></level>
                    <level lastx="false">
                        <level>
                            <toggler></toggler>
                        </level>
                    </level>
like image 764
AlexW Avatar asked Aug 31 '25 05:08

AlexW


1 Answers

With a CSS selector for an element with a title starting with "4G Signal quality":

driver.find_element_by_css_selector("[title^='4G Signal quality']")

, or containing "4G Signal quality":

driver.find_element_by_css_selector("[title*='4G Signal quality']")
like image 147
michael Avatar answered Sep 02 '25 19:09

michael