Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Click an icon on a browser
#1
I have currently written a code that clicks around on share point using selenium on Microsoft edge. On one of the pages there are two areas that when you click on them the option bar at the top changes depending what area you click on and I need to get to the right area to click the right options. I am trying to click in the right area but currently I won't let me and I get an error that reads
selenium.common.exceptions.NoSuchElementException: Message: No such element
what im trying to use is

driver.find_element_by_id("QCB1").click()
when I go to the area and right click to inspect element this is the html code for that area. (I got this from the internet explorer browser)

<div class="ms-listview-qcbContainer">
     <div class="ms-qcb-root" id="QCB1">
          <ul class="ms-qcb-zone ms-qcb-leftzone">
                <li class="ms-qcb-item">
                    <button title="Create a new document or folder in this library." class="ms-qcb-button js-listview-qcbNewButton js-callout-body js-qcb-button js-callout-                     launchPoint" id="QCB1_Button1" role="button" accesskey="n" onclick='Renderer.FunctionDispatcher.Execute
                     (this,0,"itemClick",event,Renderer.FunctionDispatcher.GetObject(0))' type="button" aira-expanded="false">
                      <span class="ms-qcb-glyph ms-listview-glyphwithmargin   
                      ms-core-form-heading ms-listview-new-glyph ms-listview-new-glyph-circle "></span>New<span class="ms-qcb-glyph  ">
                      </span></button></li>
<li class="ms-qcb-item"><button title="Upload a document from your computer to this library." class="ms-qcb-button ms-qcb-buttons-alignmentfix js-listview-qcbUploadButton js-callout-body js-qcb-button " id="QCB1_Button2" role="button" accesskey="u" onclick='Renderer.FunctionDispatcher.Execute(this,0,"itemClick",event,Renderer.FunctionDispatcher.GetObject(1))' type="button" aira-expanded="false"><span class="ms-qcb-glyph ms-listview-glyph-withmargin ms-core-form-heading "></span>Upload<span class="ms-qcb-glyph  "></span></button></li>

<li class="ms-qcb-item"><button title="Create a synchronized copy of this library on your computer." class="ms-qcb-button ms-qcb-buttons-alignmentfix js-listview-qcbSyncButton js-callout-body js-qcb-button " id="QCB1_Button3" role="button" accesskey="y" onclick='Renderer.FunctionDispatcher.Execute(this,0,"itemClick",event,Renderer.FunctionDispatcher.GetObject(2))' type="button" aira-expanded="false"><span class="ms-qcb-glyph ms-listview-glyph-withmargin ms-listview-sync-glyph ms-core-form-heading "></span>Sync<span class="ms-qcb-glyph  "></span></button></li>

<li class="ms-qcb-item"><button title="Invite people to a selected document or folder." class="ms-qcb-button ms-qcb-buttons-alignmentfix js-listview-qcbShareButton js-callout-body js-qcb-button " id="QCB1_Button4" role="button" accesskey="s" onclick='Renderer.FunctionDispatcher.Execute(this,0,"itemClick",event,Renderer.FunctionDispatcher.GetObject(3))' type="button" aira-expanded="false"><span class="ms-qcb-glyph ms-listview-glyph-withmargin ms-core-form-heading "></span>Share<span class="ms-qcb-glyph  "></span></button></li>

<li class="ms-qcb-item"><button title="Do other activities with selected documents or folders." class="ms-qcb-button ms-qcb-buttons-alignmentfix js-listview-qcbManageButton js-callout-body js-qcb-button " id="QCB1_Button5" role="button" accesskey="m" onclick='Renderer.FunctionDispatcher.Execute(this,0,"itemClick",event,Renderer.FunctionDispatcher.GetObject(4))' type="button" aira-expanded="false"><span class="ms-qcb-glyph  "></span>More<span class="ms-qcb-glyph ms-listview-manage-glyph ms-toolbar "></span></button></li>
            </ul><ul class="ms-qcb-zone ms-qcb-rightzone">
                
            </ul><hr class="ms-qcb-clearSeparator"></div></div>
Reply
#2
1) you could try clicking on the actual <button> tag...and yes it will have a long class_name. I had one instance where i had to click on the deeper nested element. You might even want to try to click on the <span> tag embedded in the button even.
2) Is this piece of code contained in an iframe?
3) Do you have a timeout code set?
4) Is your code going to fast? Try a test delay between loading that portion of the page, and actually clicking the element. Sometimes the page hasnt even loaded yet before the search and click occurs.
Recommended Tutorials:
Reply
#3
(Aug-09-2018, 12:54 PM)metulburr Wrote: 1) you could try clicking on the actual <button> tag...and yes it will have a long class_name. I had one instance where i had to click on the deeper nested element. You might even want to try to click on the <span> tag embedded in the button even.
2) Is this piece of code contained in an iframe?
3) Do you have a timeout code set?
4) Is your code going to fast? Try a test delay between loading that portion of the page, and actually clicking the element. Sometimes the page hasnt even loaded yet before the search and click occurs.

to answer the questions
1) there isn't a specific button I am trying to click just an area maybe around the center. so the code for a bar in the area is

 <div class="ms-qcb-root" id="QCB1"> 
2)I don't think it is part of an iframe, its all on one webpage and its not importing anything from another page.

3)yes I have a timeout code currently I am using
 driver.implicitly_wait(15) 
4)My code is going pretty fast but the implicit wait is what I've been using so that it reads it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  webdriver.remote to connect back existing browser without open new browser? gahhon 6 6,736 Feb-26-2019, 03:53 PM
Last Post: gahhon
  Click in the (…) icon in youtube with selenium PyChrome AcszE 6 16,238 Oct-19-2017, 02:45 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020