Issue
I'm new to Selenium Python and trying to loop through a list of menu items, and when I get to a specific menu item I want to see if it's expanded or not. Based on how the code is set up, the only way I can see to do this is see if the aria-expanded element is set to true.
So my problem is two-fold: 1) How do I best loop through the menu items until I get to "Workloads" and 2) how do I determine if Workloads is expanded or not.
My first thought was to do a For loop by class-name for "ng-star-inserted" class, but that class is used in other areas of the page and I was getting an error in trying to look for the class "category-name" in the For loop. Everything that I've read that could help is to use the XPath, but I'm not familiar enough with the syntax of XPath to know what I'm doing so I keep getting errors.
Below is the relevant code, any help you can provide would be so, so appreciated!!
<vdl-sidenav-scroll class="sidenav-scrollable-container vdl-sidenav-scroll">
<div cdkscrollable="" class="vdl-scroll-container" tabindex="-1">
<div class="vdl-sidenav-list" role="list">
<!---->
<div class="ng-star-inserted">
<vdl-sidenav-item class="vdl-tooltip-trigger selected vdl-sidenav-item" role="listitem" tabindex="0" vdltooltipclasses="vdl-tooltip-popover" vdltooltiphidedelay="300" vdltooltipposition="right" vdltooltipshowdelay="300" aria-expanded="false" aria-selected="true" aria-describedby="cdk-describedby-message-2" cdk-describedby-host="">
<div class="category-icon">
<!---->
<div>
<!---->
<vdl-icon class="category-icon vdl-icon notranslate fa fa-dashboard ng-star-inserted" fontset="fontawesome" role="img" vdl-list-icon="" aria-hidden="true" data-vdl-icon-type="font" data-vdl-icon-name="fa-dashboard" data-vdl-icon-namespace="fontawesome">
<!---->
</vdl-icon>
<!---->
</div>
</div>
<!---->
<div class="category-name ng-star-inserted">
Dashboard
</div>
<!---->
<!---->
</vdl-sidenav-item>
<!---->
</div>
<div class="ng-star-inserted">
<vdl-sidenav-item class="vdl-tooltip-trigger vdl-sidenav-item" role="listitem" tabindex="0" vdltooltipclasses="vdl-tooltip-popover" vdltooltiphidedelay="300" vdltooltipposition="right" vdltooltipshowdelay="300" aria-expanded="false" aria-selected="false" aria-describedby="cdk-describedby-message-3" cdk-describedby-host="">
<div class="category-icon">
<!---->
<div>
<!---->
<!---->
<vdl-icon class="category-icon vdl-icon notranslate ng-star-inserted" role="img" vdl-list-icon="" aria-hidden="true" data-vdl-icon-type="svg" data-vdl-icon-name="successful-job">
<svg width="100%" height="100%" viewBox="0 0 14 19" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fit="" preserveAspectRatio="xMidYMid meet" focusable="false">
<!-- Generator: Sketch 44.1 (41455) - http://www.bohemiancoding.com/sketch -->
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Iconography---" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Artboard" transform="translate(-126.000000, -414.000000)" fill="#3B73B4">
<g id="ActivityMon_Status" transform="translate(20.000000, 175.000000)">
<g id="Outlines" transform="translate(95.000000, 14.000000)">
<path d="M24.1160714,229.973214 L20.8571429,233.232143 L20.8571429,242.428571 C20.8571429,242.770835 20.7343762,243.064731 20.4888393,243.310268 C20.2433023,243.555805 19.9494065,243.678571 19.6071429,243.678571 C19.2648792,243.678571 18.9709834,243.555805 18.7254464,243.310268 C18.4799095,243.064731 18.3571429,242.770835 18.3571429,242.428571 L18.3571429,238.142857 L17.6428571,238.142857 L17.6428571,242.428571 C17.6428571,242.770835 17.5200905,243.064731 17.2745536,243.310268 C17.0290166,243.555805 16.7351208,243.678571 16.3928571,243.678571 C16.0505935,243.678571 15.7566977,243.555805 15.5111607,243.310268 C15.2656238,243.064731 15.1428571,242.770835 15.1428571,242.428571 L15.1428571,233.232143 L11.8839286,229.973214 C11.6755942,229.76488 11.5714286,229.511906 11.5714286,229.214286 C11.5714286,228.916665 11.6755942,228.663692 11.8839286,228.455357 C12.0997035,228.247023 12.3545372,228.142857 12.6484375,228.142857 C12.9423378,228.142857 13.1934513,228.247023 13.4017857,228.455357 L15.9464286,231 L20.0535714,231 L22.5982143,228.455357 C22.8065487,228.247023 23.0595223,228.142857 23.3571429,228.142857 C23.6547634,228.142857 23.9077371,228.247023 24.1160714,228.455357 C24.3244058,228.671132 24.4285714,228.925966 24.4285714,229.219866 C24.4285714,229.513766 24.3244058,229.76488 24.1160714,229.973214 Z M20.5,228.142857 C20.5,228.834825 20.2563268,229.424477 19.7689732,229.91183 C19.2816196,230.399184 18.6919677,230.642857 18,230.642857 C17.3080323,230.642857 16.7183804,230.399184 16.2310268,229.91183 C15.7436732,229.424477 15.5,228.834825 15.5,228.142857 C15.5,227.450889 15.7436732,226.861238 16.2310268,226.373884 C16.7183804,225.88653 17.3080323,225.642857 18,225.642857 C18.6919677,225.642857 19.2816196,225.88653 19.7689732,226.373884 C20.2563268,226.861238 20.5,227.450889 20.5,228.142857 Z" id="svg-icon"></path>
</g>
</g>
</g>
</g>
</svg>
</vdl-icon>
</div>
</div>
<!---->
<div class="category-name ng-star-inserted">
Activity monitor
</div>
<!---->
<!---->
</vdl-sidenav-item>
<!---->
</div>
<div class="ng-star-inserted">
<vdl-sidenav-item class="vdl-tooltip-trigger vdl-sidenav-item" role="listitem" tabindex="0" vdltooltipclasses="vdl-tooltip-popover" vdltooltiphidedelay="300" vdltooltipposition="right" vdltooltipshowdelay="300" aria-expanded="false" aria-selected="false" aria-describedby="cdk-describedby-message-4" cdk-describedby-host="">
<div class="category-icon">
<!---->
<div>
<!---->
<vdl-icon class="category-icon vdl-icon notranslate fa fa-shield ng-star-inserted" fontset="fontawesome" role="img" vdl-list-icon="" aria-hidden="true" data-vdl-icon-type="font" data-vdl-icon-name="fa-shield" data-vdl-icon-namespace="fontawesome">
<!---->
</vdl-icon>
<!---->
</div>
</div>
<!---->
<div class="category-name ng-star-inserted">
Protection
</div>
<!---->
<!---->
<div class="category-expander ng-star-inserted">
<vdl-icon class="sidenav-icon vdl-icon notranslate fa fa-angle-down" fonticon="fa-angle-down" fontset="fontawesome" role="img" aria-hidden="true" data-vdl-icon-type="font" data-vdl-icon-name="fa-angle-down" data-vdl-icon-namespace="fontawesome">
<!---->
</vdl-icon>
</div>
</vdl-sidenav-item>
<!---->
</div>
<div class="ng-star-inserted">
<vdl-sidenav-item class="vdl-tooltip-trigger vdl-sidenav-item" role="listitem" tabindex="0" vdltooltipclasses="vdl-tooltip-popover" vdltooltiphidedelay="300" vdltooltipposition="right" vdltooltipshowdelay="300" aria-expanded="true" aria-selected="false" aria-describedby="cdk-describedby-message-5" cdk-describedby-host="">
<div class="category-icon">
<!---->
<div>
<!---->
<vdl-icon class="category-icon vdl-icon notranslate fa fa-briefcase ng-star-inserted" fontset="fontawesome" role="img" vdl-list-icon="" aria-hidden="true" data-vdl-icon-type="font" data-vdl-icon-name="fa-briefcase" data-vdl-icon-namespace="fontawesome">
<!---->
</vdl-icon>
<!---->
</div>
</div>
<!---->
<div class="category-name ng-star-inserted">
Workloads
</div>
<!---->
<!---->
<div class="category-expander ng-star-inserted">
<vdl-icon class="sidenav-icon vdl-icon notranslate fa fa-angle-down expanded" fonticon="fa-angle-down" fontset="fontawesome" role="img" aria-hidden="true" data-vdl-icon-type="font" data-vdl-icon-name="fa-angle-down" data-vdl-icon-namespace="fontawesome">
<!---->
</vdl-icon>
</div>
</vdl-sidenav-item>
<!---->
<div class="ng-star-inserted">
<!---->
<div class="ng-star-inserted">
<vdl-sidenav-item class="sub-category-indent vdl-tooltip-trigger vdl-sidenav-item" role="listitem" tabindex="0" vdltooltipclasses="vdl-tooltip-popover" vdltooltiphidedelay="300" vdltooltipposition="right" vdltooltipshowdelay="300" aria-expanded="false" aria-selected="false" aria-describedby="cdk-describedby-message-10" cdk-describedby-host="">
<div class="category-icon">
<!---->
<div>
<!---->
<!---->
<vdl-icon class="category-icon vdl-icon notranslate ng-star-inserted" role="img" vdl-list-icon="" aria-hidden="true" data-vdl-icon-type="svg" data-vdl-icon-name="database-mssql">
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20" fit="" height="100%" width="100%" preserveAspectRatio="xMidYMid meet" focusable="false">
<defs>
<style>
.cls-1 {
fill: none;
}
.cls-2 {
clip-path: url(#clip-path);
}
.cls-3 {
clip-path: url(#clip-path-2);
}
.cls-4 {
fill: #f9f9fa;
}
</style>
<clipPath id="clip-path">
<circle class="cls-1" cx="-657.86" cy="-220.61" r="5.5"></circle>
</clipPath>
<clipPath id="clip-path-2">
<polygon class="cls-1" points="-659.64 -218.11 -659.64 -220.08 -659.71 -222.09 -659.69 -222.1 -658.08 -218.11 -657.63 -218.11 -656.02 -222.11 -656 -222.1 -656.07 -220.08 -656.07 -218.11 -655.4 -218.11 -655.4 -223.09 -656.26 -223.09 -657.85 -219.05 -657.87 -219.05 -659.45 -223.09 -660.32 -223.09 -660.32 -218.11 -659.64 -218.11"></polygon>
</clipPath>
</defs><path class="cls-1" d="M8.32,13.06A7.49,7.49,0,0,1,7,12.58L6.61,13.7a5.35,5.35,0,0,0,.64.27l.29-.76h0l0,.86c.25.08.51.16.79.22Z"></path><path class="cls-1" d="M7.48,16.35v.78h.84v-.5C8,16.54,7.73,16.45,7.48,16.35Z"></path><path class="cls-1" d="M6,15.38,5.77,16h0L4.29,12.07H3.2v5.06H4V15.4L4,13.22H4l1.49,3.91H6l.48-1.27A2.14,2.14,0,0,1,6,15.38Z"></path><path class="cls-4" d="M12.47,11.3A22,22,0,0,1,9.15,11a5.64,5.64,0,0,1,1.35,2.69c.63,0,1.29.08,2,.08a19.46,19.46,0,0,0,3.78-.34A9.1,9.1,0,0,0,19,12.56c.67-.39,1-.81,1-1.26V9.63a8.53,8.53,0,0,1-3.19,1.25A21.41,21.41,0,0,1,12.47,11.3Z"></path><path class="cls-4" d="M19,1.26A8.81,8.81,0,0,0,16.25.34,19.46,19.46,0,0,0,12.47,0,19.46,19.46,0,0,0,8.69.34a8.81,8.81,0,0,0-2.75.92c-.68.38-1,.8-1,1.25V3.77c0,.45.33.87,1,1.25a9.08,9.08,0,0,0,2.75.92,19.46,19.46,0,0,0,3.78.34,19.46,19.46,0,0,0,3.78-.34A9.08,9.08,0,0,0,19,5c.67-.38,1-.8,1-1.25V2.51C20,2.06,19.67,1.64,19,1.26Z"></path><path class="cls-4" d="M12.47,7.53a21.41,21.41,0,0,1-4.35-.42A8.53,8.53,0,0,1,4.93,5.87V7.53c0,.46.33.87,1,1.26a9.08,9.08,0,0,0,2.75.92,20.28,20.28,0,0,0,3.78.34,20.28,20.28,0,0,0,3.78-.34A9.08,9.08,0,0,0,19,8.79c.67-.39,1-.8,1-1.26V5.87a8.53,8.53,0,0,1-3.19,1.24A21.41,21.41,0,0,1,12.47,7.53Z"></path><path class="cls-4" d="M12.47,15.07c-.65,0-1.27,0-1.88-.09a5.62,5.62,0,0,1-.66,2.44,22.77,22.77,0,0,0,2.54.16,19.46,19.46,0,0,0,3.78-.34A8.81,8.81,0,0,0,19,16.32c.67-.38,1-.8,1-1.25V13.4a8.53,8.53,0,0,1-3.19,1.25A21.41,21.41,0,0,1,12.47,15.07Z"></path><path class="cls-4" d="M4.91,9.9a4.9,4.9,0,1,0,4.91,4.89A4.9,4.9,0,0,0,4.91,9.9Zm2.7,3.32v4.29H6.72V15.69l.06-1.41,0-.9h0l-.31.8-.76,2-.51,1.33h-.6L3,13.39H3l.09,2.3v1.82H2.21V12.18H3.36l1.54,4.1h0l.23-.61.66-1.77.45-1.18.2-.54H7.61Z"></path></svg>
</vdl-icon>
</div>
</div>
<!---->
<div class="category-name ng-star-inserted">
Microsoft SQL Server
</div>
<!---->
<!---->
</vdl-sidenav-item>
</div>
<div class="ng-star-inserted">
<vdl-sidenav-item class="sub-category-indent vdl-tooltip-trigger vdl-sidenav-item" role="listitem" tabindex="0" vdltooltipclasses="vdl-tooltip-popover" vdltooltiphidedelay="300" vdltooltipposition="right" vdltooltipshowdelay="300" aria-expanded="false" aria-selected="false" aria-describedby="cdk-describedby-message-11" cdk-describedby-host="">
<div class="category-icon">
<!---->
<div>
<!---->
<!---->
<vdl-icon class="category-icon vdl-icon notranslate ng-star-inserted" role="img" vdl-list-icon="" aria-hidden="true" data-vdl-icon-type="svg" data-vdl-icon-name="database-oracle">
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20" fit="" height="100%" width="100%" preserveAspectRatio="xMidYMid meet" focusable="false">
<defs>
<style>
.cls-1 {
fill: none;
}
.cls-2 {
clip-path: url(#clip-path);
}
.cls-3 {
clip-path: url(#clip-path-2);
}
.cls-4 {
fill: #f9f9fa;
}
</style>
<clipPath id="clip-path">
<circle class="cls-1" cx="-657.86" cy="-243.46" r="5.5"></circle>
</clipPath>
<clipPath id="clip-path-2">
<polygon class="cls-1" points="-659.64 -240.96 -659.64 -242.93 -659.71 -244.94 -659.69 -244.94 -658.08 -240.96 -657.63 -240.96 -656.02 -244.95 -656 -244.95 -656.07 -242.93 -656.07 -240.96 -655.4 -240.96 -655.4 -245.93 -656.26 -245.93 -657.85 -241.89 -657.87 -241.89 -659.45 -245.93 -660.32 -245.93 -660.32 -240.96 -659.64 -240.96"></polygon>
</clipPath>
</defs><path class="cls-4" d="M12.46,11.39a22,22,0,0,1-3.32-.27,5.71,5.71,0,0,1,1.35,2.7c.63,0,1.29.08,2,.08a19.46,19.46,0,0,0,3.78-.34A9.2,9.2,0,0,0,19,12.65c.67-.39,1-.81,1-1.26V9.72A8.53,8.53,0,0,1,16.81,11,21.41,21.41,0,0,1,12.46,11.39Z"></path><path class="cls-4" d="M19,1.34A9.2,9.2,0,0,0,16.24.43,19.46,19.46,0,0,0,12.46.09,19.46,19.46,0,0,0,8.68.43a9.1,9.1,0,0,0-2.75.91c-.68.39-1,.81-1,1.26V3.86c0,.45.33.86,1,1.25A9.08,9.08,0,0,0,8.68,6a20.28,20.28,0,0,0,3.78.34A20.28,20.28,0,0,0,16.24,6,9.18,9.18,0,0,0,19,5.11c.67-.39,1-.8,1-1.25V2.6C20,2.15,19.66,1.73,19,1.34Z"></path><path class="cls-4" d="M12.46,7.62A21.41,21.41,0,0,1,8.11,7.2,8.46,8.46,0,0,1,4.92,6V7.62c0,.45.33.87,1,1.26a9.36,9.36,0,0,0,2.75.92,20.31,20.31,0,0,0,3.78.33,20.31,20.31,0,0,0,3.78-.33A9.47,9.47,0,0,0,19,8.88c.67-.39,1-.81,1-1.26V6A8.53,8.53,0,0,1,16.81,7.2,21.41,21.41,0,0,1,12.46,7.62Z"></path><path class="cls-4" d="M12.46,15.16c-.65,0-1.27,0-1.88-.09a5.54,5.54,0,0,1-.66,2.43,20.43,20.43,0,0,0,2.54.17,20.28,20.28,0,0,0,3.78-.34A9.18,9.18,0,0,0,19,16.41c.67-.38,1-.8,1-1.25V13.49a8.53,8.53,0,0,1-3.19,1.24A20.7,20.7,0,0,1,12.46,15.16Z"></path><path class="cls-4" d="M4.88,12.88a1.06,1.06,0,0,0-.88.4,1.6,1.6,0,0,0-.33,1v.92a1.6,1.6,0,0,0,.33,1,1,1,0,0,0,.88.41,1.1,1.1,0,0,0,.91-.4,1.56,1.56,0,0,0,.34-1v-.92a1.55,1.55,0,0,0-.34-1A1.13,1.13,0,0,0,4.88,12.88Z"></path><path class="cls-4" d="M4.9,10a4.9,4.9,0,1,0,4.9,4.9A4.91,4.91,0,0,0,4.9,10ZM7,15.24a2.1,2.1,0,0,1-.58,1.53,2,2,0,0,1-1.51.61,1.92,1.92,0,0,1-1.48-.61,2.13,2.13,0,0,1-.57-1.53v-.91a2.17,2.17,0,0,1,.57-1.54,2,2,0,0,1,1.48-.61,2,2,0,0,1,1.51.61A2.18,2.18,0,0,1,7,14.33Z"></path></svg>
</vdl-icon>
</div>
</div>
<!---->
<div class="category-name ng-star-inserted">
Oracle
</div>
<!---->
<!---->
</vdl-sidenav-item>
</div>
</div>
</div>
<div class="ng-star-inserted">
<vdl-sidenav-item class="vdl-tooltip-trigger vdl-sidenav-item" role="listitem" tabindex="0" vdltooltipclasses="vdl-tooltip-popover" vdltooltiphidedelay="300" vdltooltipposition="right" vdltooltipshowdelay="300" aria-expanded="false" aria-selected="false" aria-describedby="cdk-describedby-message-6" cdk-describedby-host="">
<div class="category-icon">
<!---->
<div>
<!---->
<!---->
<vdl-icon class="category-icon vdl-icon notranslate ng-star-inserted" role="img" vdl-list-icon="" aria-hidden="true" data-vdl-icon-type="svg" data-vdl-icon-name="credential-management-logo">
<svg width="100%" height="100%" viewBox="0 0 19 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fit="" preserveAspectRatio="xMidYMid meet" focusable="false">
<!-- Generator: Sketch 61.2 (89653) - https://sketch.com -->
<g id="Final-Side-Nav" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M15.3571429,0 L15.5379813,0.00819614955 C15.9522066,0.0464448475 16.312314,0.218563988 16.6183036,0.524553571 C16.968006,0.874255952 17.1428571,1.29464286 17.1428571,1.78571429 L17.1428571,1.78571429 L17.1428571,4.28571429 L18.2142857,4.28571429 L18.288923,4.29199219 C18.3600725,4.30454799 18.4207589,4.3359375 18.4709821,4.38616071 C18.5379464,4.453125 18.5714286,4.53869048 18.5714286,4.64285714 L18.5714286,4.64285714 L18.5714286,6.78571429 L18.5651507,6.86035156 C18.5525949,6.93150112 18.5212054,6.9921875 18.4709821,7.04241071 C18.4040179,7.109375 18.3184524,7.14285714 18.2142857,7.14285714 L18.2142857,7.14285714 L17.1428571,7.14285714 L17.1428571,8.57142857 L18.2142857,8.57142857 L18.288923,8.57770647 C18.3600725,8.59026228 18.4207589,8.62165179 18.4709821,8.671875 C18.5379464,8.73883929 18.5714286,8.82440476 18.5714286,8.92857143 L18.5714286,8.92857143 L18.5714286,11.0714286 L18.5651507,11.1460658 C18.5525949,11.2172154 18.5212054,11.2779018 18.4709821,11.328125 C18.4040179,11.3950893 18.3184524,11.4285714 18.2142857,11.4285714 L18.2142857,11.4285714 L17.1428571,11.4285714 L17.1428571,12.8571429 L18.2142857,12.8571429 L18.288923,12.8634208 C18.3600725,12.8759766 18.4207589,12.9073661 18.4709821,12.9575893 C18.5379464,13.0245536 18.5714286,13.110119 18.5714286,13.2142857 L18.5714286,13.2142857 L18.5714286,15.3571429 L18.5651507,15.4317801 C18.5525949,15.5029297 18.5212054,15.5636161 18.4709821,15.6138393 C18.4040179,15.6808036 18.3184524,15.7142857 18.2142857,15.7142857 L18.2142857,15.7142857 L17.1428571,15.7142857 L17.1428571,18.2142857 L17.134661,18.3951242 C17.0964123,18.8093494 16.9242932,19.1694568 16.6183036,19.4754464 C16.2686012,19.8251488 15.8482143,20 15.3571429,20 L15.3571429,20 L1.78571429,20 L1.60487584,19.9918039 C1.19065058,19.9535552 0.830543155,19.781436 0.524553571,19.4754464 C0.17485119,19.125744 5.5067062e-14,18.7053571 5.5067062e-14,18.2142857 L5.5067062e-14,18.2142857 L5.5067062e-14,1.78571429 L0.00819614955,1.60487584 C0.0464448475,1.19065058 0.218563988,0.830543155 0.524553571,0.524553571 C0.874255952,0.17485119 1.29464286,0 1.78571429,0 L1.78571429,0 L15.3571429,0 Z M7.2875817,5 C6.59041394,5 5.90849673,5.19891122 5.24183007,5.59673367 C4.5751634,5.99455611 4.03485839,6.5138191 3.62091503,7.15452261 C3.20697168,7.79522613 3,8.45058626 3,9.12060302 C3,9.80318258 3.22331155,10.3590871 3.66993464,10.7883166 C4.11655773,11.2175461 4.69498911,11.4321608 5.40522876,11.4321608 C6.14640523,11.4321608 6.86464052,11.2099874 7.55993464,10.7656407 L7.79084967,10.6092965 L12.1764706,14.8241206 C12.2984749,14.9413735 12.4466231,15 12.620915,15 C12.8039216,15 12.9803922,14.9183417 13.1503268,14.7550251 C13.3202614,14.5917085 13.4052288,14.4221106 13.4052288,14.2462312 C13.4052288,14.1122278 13.3661874,13.9943049 13.2881046,13.8924623 L13.2222222,13.8190955 L11.7843137,12.4371859 L12.4117647,11.8341709 C12.4248366,11.8467337 12.4782135,11.9011725 12.5718954,11.9974874 C12.6655773,12.0938023 12.7494553,12.1775544 12.8235294,12.2487437 C12.8976035,12.319933 12.9771242,12.3890285 13.0620915,12.4560302 C13.1470588,12.5230318 13.2091503,12.5565327 13.248366,12.5565327 C13.3224401,12.5565327 13.4662309,12.4539363 13.6797386,12.2487437 C13.8932462,12.0435511 14,11.9053601 14,11.8341709 C14,11.80067 13.9379085,11.7148241 13.8137255,11.5766332 C13.6895425,11.4384422 13.5305011,11.2751256 13.3366013,11.0866834 C13.1427015,10.8982412 12.9542484,10.7181742 12.7712418,10.5464824 C12.5882353,10.3747906 12.4095861,10.2083333 12.2352941,10.0471106 C12.0610022,9.88588777 11.9607843,9.79271357 11.9346405,9.76758794 C11.8910675,9.72571189 11.8409586,9.70477387 11.7843137,9.70477387 C11.7102397,9.70477387 11.5664488,9.80737018 11.3529412,10.0125628 C11.1394336,10.2177554 11.0326797,10.3559464 11.0326797,10.4271357 C11.0326797,10.4648241 11.0675381,10.5244975 11.1372549,10.6061558 C11.2069717,10.6878141 11.2788671,10.7642379 11.3529412,10.8354271 C11.4270153,10.9066164 11.5141612,10.9872278 11.6143791,11.0772613 C11.6945534,11.1492881 11.746841,11.1965243 11.7712418,11.2189698 L11.7843137,11.2311558 L11.1568627,11.8341709 L8.83660131,9.60427136 C9.40740741,8.86725293 9.69281046,8.10301508 9.69281046,7.31155779 C9.69281046,6.62897822 9.46949891,6.0730737 9.02287582,5.64384422 C8.57625272,5.21461474 7.99782135,5 7.2875817,5 Z M7.18300654,6.20603015 C7.53159041,6.20603015 7.82788671,6.32328308 8.07189542,6.55778894 C8.31590414,6.79229481 8.4379085,7.07705193 8.4379085,7.4120603 C8.4379085,7.74706868 8.31590414,8.0318258 8.07189542,8.26633166 C7.82788671,8.50083752 7.53159041,8.61809045 7.18300654,8.61809045 C7,8.61809045 6.81917211,8.57830821 6.64052288,8.49874372 C6.72331155,8.67043551 6.76470588,8.84422111 6.76470588,9.0201005 C6.76470588,9.35510888 6.64270153,9.639866 6.39869281,9.87437186 C6.1546841,10.1088777 5.8583878,10.2261307 5.50980392,10.2261307 C5.16122004,10.2261307 4.86492375,10.1088777 4.62091503,9.87437186 C4.37690632,9.639866 4.25490196,9.35510888 4.25490196,9.0201005 C4.25490196,8.68509213 4.37690632,8.40033501 4.62091503,8.16582915 C4.86492375,7.93132328 5.16122004,7.81407035 5.50980392,7.81407035 C5.69281046,7.81407035 5.87363834,7.8538526 6.05228758,7.93341709 C5.96949891,7.76172529 5.92810458,7.5879397 5.92810458,7.4120603 C5.92810458,7.07705193 6.05010893,6.79229481 6.29411765,6.55778894 C6.53812636,6.32328308 6.83442266,6.20603015 7.18300654,6.20603015 Z" id="svg-icon" fill="#F9F9F9" fill-rule="nonzero"></path>
</g>
</svg>
</vdl-icon>
</div>
</div>
<!---->
<div class="category-name ng-star-inserted">
Credential management
</div>
<!---->
<!---->
</vdl-sidenav-item>
<!---->
</div>
</div>
</div>
<div class="vdl-scroll-rail" style="display: none;">
<div cdkdrag="" cdkdragboundary=".vdl-scroll-rail" cdkdraglockaxis="y" class="vdl-scroll-bar cdk-drag"></div>
</div>
Solution
If you know the specific element to test. Identify the element using the xpath.
elementWorkLoad=driver.find_element(By.XPATH, "//div[@class='category-name ng-star-inserted' and normalize-space(.)='Workloads']")
Then use the parent node attribute to check whether it is expanded.
if elementWorkLoad.find_element(By.XPATH, "./parent::vdl-sidenav-item[1]").get_attribute("aria-expanded"):
print("It is expanded!")
If you really need a loop then try this one.
for element in driver.find_elements(By.XPATH, "//div[@class='category-name ng-star-inserted'"):
if element.text.strip()="Workloads":
print("element found!")
if element.find_element(By.XPATH, "./parent::vdl-sidenav-item[1]").get_attribute("aria-expanded"):
print("It is expanded!")
Answered By - KunduK
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.