So I am having issues with selenium clicking hidden nav bar in HTML...I need to click on the action button and then click on Export(Excel).
Currently, I have it set to aria-labeledby=share and this assumes I want to click Export(CSV) and performs the task (when the script wants to work...if not then I get the error below). When I try to set the find_elements_by_css_selector()
or find_elements_by_xpath()
and point it to Export(Excel) it doesn't work. So I currently have it set to aria-labeledby=Share and this works but randomly it will stop working and I will get the below error. I have never heard of WAI-Aria embedded into HTML until inspected the webpage element.
action = ActionChains(driver)
aria_lablededBy = driver.find_elements_by_css_selector("[aria-labeledby=Actions]")[0]
action.move_to_element(aria_lablededBy).click(aria_lablededBy).perform()
share = driver.find_elements_by_css_selector('[aria-labeledby=Share]')[0]
action.move_to_element(share).click(share).perform()
the above code works and then stops randomly and i get this error message
ERROR:
Traceback (most recent call last):
File "c:/Users/xxxxx/Desktop/Python/import/export.py", line 53, in <module>
action.move_to_element(share).click(share).perform()
File "C:\Anaconda\lib\site-packages\selenium\webdriver\common\action_chains.py", line 80, in perform
self.w3c_actions.perform()
File "C:\Anaconda\lib\site-packages\selenium\webdriver\common\actions\action_builder.py", line 76, in perform
self.driver.execute(Command.W3C_ACTIONS, enc)
File "C:\Anaconda\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Anaconda\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite.
(Session info: chrome=87.0.4280.88)
the HTML site that I am connecting to has Aria-HTML code and I am not familiar with that. I removed the shared variable and the following action on the shared variable and the script will open up the actions nav...once enable the shared variable and the action then it gives me the error
I am way out of my league on this problem so if anyone in the community knows how to solve this problem I am very interested.
HTML CODE - Action Menu Hidden
<lp-mega-menu _ngcontent-iyn-c45="" _nghost-iyn-c31="">
<nav _ngcontent-iyn-c31="" class="dropdown" lpmegamenu="" role="menu" triggers="manual" id="KJ0X5NWLXZGZ8" aria-labeledby="Actions">
<button _ngcontent-iyn-c31="" aria-haspopup="true" tabindex="0" type="button" class="lp-themed-button lp-themed-primary-button" aria-controls="dropdown-menu-KJ0X5NWLXZGZ8" aria-expanded="false">
<!----><!----><!----><span _ngcontent-iyn-c31="">Actions</span><i _ngcontent-iyn-c31="" class="fas fa-caret-down mr-0 ml-default-half"></i>
</button>
<div _ngcontent-iyn-c31="" class="dropdown-menu dropdown-menu-right mega-menu-panel my-2" id="dropdown-menu-KJ0X5NWLXZGZ8" aria-hidden="true" style="max-height: 600px;">
<!---->
<div _ngcontent-iyn-c31="" class="mega-menu-panel-wrapper label-reset ul-reset">
<!----><!----><!---->
<div _ngcontent-iyn-c31="" class="mega-menu-grid">
<!----><!----><!---->
<div _ngcontent-iyn-c31="" class="mega-menu-col">
<div _ngcontent-iyn-c31="" class="mega-menu-body">
<label _ngcontent-iyn-c31="">Authoring</label>
<div _ngcontent-iyn-c31="" class="mega-menu-content">
<ul _ngcontent-iyn-c31="" aria-labeledby="Authoring">
<!---->
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Add Record"><span _ngcontent-iyn-c31="">Add</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Filter Report"><span _ngcontent-iyn-c31="">Filters (0)</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Edit Report"><span _ngcontent-iyn-c31="">Edit</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Copy Report"><span _ngcontent-iyn-c31="">Copy</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Delete Report"><span _ngcontent-iyn-c31="">Delete</span></a><!---->
</li>
</ul>
</div>
</div>
</div>
<!---->
<div _ngcontent-iyn-c31="" class="mega-menu-col">
<div _ngcontent-iyn-c31="" class="mega-menu-body">
<label _ngcontent-iyn-c31="">Bulk Ops</label>
<div _ngcontent-iyn-c31="" class="mega-menu-content">
<ul _ngcontent-iyn-c31="" aria-labeledby="Bulk Ops">
<!---->
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Bulk Edit Records"><span _ngcontent-iyn-c31="">Edit</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Bulk Move Records"><span _ngcontent-iyn-c31="">Move</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Bulk Edit/Move Records"><span _ngcontent-iyn-c31="">Edit/Move</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Bulk Delete Records"><span _ngcontent-iyn-c31="">Delete</span></a><!---->
</li>
</ul>
</div>
</div>
</div>
<!---->
<div _ngcontent-iyn-c31="" class="mega-menu-col-md">
<!----><!----><!---->
<div _ngcontent-iyn-c31="" class="mega-menu-body">
<label _ngcontent-iyn-c31="">Share</label>
<div _ngcontent-iyn-c31="" class="mega-menu-content">
<ul _ngcontent-iyn-c31="" aria-labeledby="Share">
<!---->
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Print a PDF"><span _ngcontent-iyn-c31="">Print (PDF)</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Export as Excel"><span _ngcontent-iyn-c31="">Export (Excel)</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Export as CSV"><span _ngcontent-iyn-c31="">Export (CSV)</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Copy Report Link"><span _ngcontent-iyn-c31="">Link</span></a><!---->
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!---->
</div>
</nav>
</lp-mega-menu>
HTML CODE - Action Menu Visible
<lp-mega-menu _ngcontent-iyn-c45="" _nghost-iyn-c31="">
<nav _ngcontent-iyn-c31="" class="dropdown open" lpmegamenu="" role="menu" triggers="manual" id="KJ0X5NWLXZGZ8" aria-labeledby="Actions">
<button _ngcontent-iyn-c31="" aria-haspopup="true" tabindex="0" type="button" class="lp-themed-button lp-themed-primary-button" aria-controls="dropdown-menu-KJ0X5NWLXZGZ8" aria-expanded="true">
<!----><!----><!----><span _ngcontent-iyn-c31="">Actions</span><i _ngcontent-iyn-c31="" class="fas fa-caret-down mr-0 ml-default-half"></i>
</button>
</nav>
</lp-mega-menu>
The below is part of the HTML - Action Menu Hidden code but once it the menu is visible the code is moved outside of this element:
<div _ngcontent-iyn-c31="" class="dropdown-menu dropdown-menu-right mega-menu-panel my-2" id="dropdown-menu-KJ0X5NWLXZGZ8" aria-hidden="false" style="max-height: 600px; display: block; height: 252px; right: 8px; top: 128px;">
<!---->
<div _ngcontent-iyn-c31="" class="mega-menu-panel-wrapper label-reset ul-reset">
<!----><!----><!---->
<div _ngcontent-iyn-c31="" class="mega-menu-grid">
<!----><!----><!---->
<div _ngcontent-iyn-c31="" class="mega-menu-col">
<div _ngcontent-iyn-c31="" class="mega-menu-body">
<label _ngcontent-iyn-c31="">Authoring</label>
<div _ngcontent-iyn-c31="" class="mega-menu-content">
<ul _ngcontent-iyn-c31="" aria-labeledby="Authoring">
<!---->
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Add Record"><span _ngcontent-iyn-c31="">Add</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Filter Report"><span _ngcontent-iyn-c31="">Filters (0)</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Edit Report"><span _ngcontent-iyn-c31="">Edit</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Copy Report"><span _ngcontent-iyn-c31="">Copy</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Delete Report"><span _ngcontent-iyn-c31="">Delete</span></a><!---->
</li>
</ul>
</div>
</div>
</div>
<!---->
<div _ngcontent-iyn-c31="" class="mega-menu-col">
<div _ngcontent-iyn-c31="" class="mega-menu-body">
<label _ngcontent-iyn-c31="">Bulk Ops</label>
<div _ngcontent-iyn-c31="" class="mega-menu-content">
<ul _ngcontent-iyn-c31="" aria-labeledby="Bulk Ops">
<!---->
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Bulk Edit Records"><span _ngcontent-iyn-c31="">Edit</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Bulk Move Records"><span _ngcontent-iyn-c31="">Move</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Bulk Edit/Move Records"><span _ngcontent-iyn-c31="">Edit/Move</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Bulk Delete Records"><span _ngcontent-iyn-c31="">Delete</span></a><!---->
</li>
</ul>
</div>
</div>
</div>
<!---->
<div _ngcontent-iyn-c31="" class="mega-menu-col-md">
<!----><!----><!---->
<div _ngcontent-iyn-c31="" class="mega-menu-body">
<label _ngcontent-iyn-c31="">Share</label>
<div _ngcontent-iyn-c31="" class="mega-menu-content">
<ul _ngcontent-iyn-c31="" aria-labeledby="Share">
<!---->
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Print a PDF"><span _ngcontent-iyn-c31="">Print (PDF)</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Export as Excel"><span _ngcontent-iyn-c31="">Export (Excel)</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Export as CSV"><span _ngcontent-iyn-c31="">Export (CSV)</span></a><!---->
</li>
<li _ngcontent-iyn-c31="">
<!----><a _ngcontent-iyn-c31="" class="lp-theme-link-focus lp-theme-link-hover lp-theme-link-active" tabindex="0" title="Copy Report Link"><span _ngcontent-iyn-c31="">Link</span></a><!---->
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!----></div
Full HTML - When Action is Hidden
You will see that the second square contains information about the dropdown menu and is under the Nav segment
Full HTML - When Action is Visble
Once you click on actions the DIV contaner is moved out of the Nav segment is now part of the Body Segment