Python Selenium Checking Checkboxes - python

For the life of me I can get chromedriver to click all these checkboxes. Either its not found or interactable.
<form class="step__form step__block" action="creation-full/step/legal-and-opt-ins" method="post" id="flow-form" enctype="multipart/form-data" novalidate="">
<input type="hidden" name="csrftoken" id="flow-csrftoken" value="52d14a6a-69d7-4c06-bbeb-3418c331892e">
<label class="step__field--label step__form__block">
<input class="step__checkbox" value="true" id="capture-opt-in-third-party-news-special-offers" data-capture-id="opt-in-third-party-news-special-offers" name="opt-in-third-party-news-special-offers" type="checkbox">
<input type="hidden" name="opt-in-third-party-news-special-offers" value="false"> <span class="step__field__indicator--checkbox"> <svg class="svg-inline--fa fa-check fa-w-16" aria-hidden="true" focusable="false" data-prefix="far" data-icon="check" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"></path></svg><!-- <i class="far fa-check"></i> --> </span> <span class="step__field--label__text">Account email will receive carefully selected news, event information and special offers about third-party products and services.</span> </label>
<div class="step__legal-checkboxes step__form__block" id="legal-checkboxes">
<input type="hidden" name="tou-agreements-implicit" value="08b946df-660a-40e4-a072-1fbde65173b1;209144" data-capture-id="tou-agreements-implicit" checked="">
<input type="hidden" name="tou-agreements-implicit" value="966f03a4-29e1-440c-b142-e54ee091e52d;93047" data-capture-id="tou-agreements-implicit" checked="">
<input type="hidden" name="tou-agreements-implicit" value="cd5930c0-2784-420c-a23d-1e0d6ff8599b;110052" data-capture-id="tou-agreements-implicit" checked="">
<label class="step__field--label step__form__block">
<input class="step__checkbox" value="41e60b3d-244d-4776-be75-e2c6b3eba9a3;187105" data-capture-id="tou-agreements-implicit" name="tou-agreements-implicit" type="checkbox" checked="">
<input type="hidden" name="tou-agreements-implicit" value=""> <span class="step__field__indicator--checkbox"> <svg class="svg-inline--fa fa-check fa-w-16" aria-hidden="true" focusable="false" data-prefix="far" data-icon="check" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"></path></svg><!-- <i class="far fa-check"></i> --> </span> <span class="step__field--label__text">I have reviewed and understand the Privacy Policy. For more information about how we use information and your rights to object, see our Blizzard Entertainment® Privacy Policy <svg class="svg-inline--fa fa-external-link fa-w-16" aria-hidden="true" focusable="false" data-prefix="far" data-icon="external-link" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M497.6,0,334.4.17A14.4,14.4,0,0,0,320,14.57V47.88a14.4,14.4,0,0,0,14.69,14.4l73.63-2.72,2.06,2.06L131.52,340.49a12,12,0,0,0,0,17l23,23a12,12,0,0,0,17,0L450.38,101.62l2.06,2.06-2.72,73.63A14.4,14.4,0,0,0,464.12,192h33.31a14.4,14.4,0,0,0,14.4-14.4L512,14.4A14.4,14.4,0,0,0,497.6,0ZM432,288H416a16,16,0,0,0-16,16V458a6,6,0,0,1-6,6H54a6,6,0,0,1-6-6V118a6,6,0,0,1,6-6H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V304A16,16,0,0,0,432,288Z"></path></svg><!-- <i class="far fa-external-link"></i> --> </span> </label>
</div>
<div class="step__legal-summary step__block end">
<div class="step__legal-summary__links step__block" id="legal-summary-links"> La La La </div>
</div>
<div class="step__button-container step__block end">
<button type="submit" class="step__button step__button--primary" id="flow-form-submit-btn">Continue</button>
</div>
any help will be appriciated. thanks

You can use this id capture-opt-in-third-party-news-special-offers which is unique in nature.
If python is your binding language, then this should work :
driver.find_element_by_css_selector("#legal-checkboxes label input").click()
or if it needs explicit waits :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 50)
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#legal-checkboxes label input"))).click()
or if both of them do not work, try JS :-
check_box = driver.find_element_by_css_selector("#legal-checkboxes label input")
driver.execute_script("arguments[0].click();", check_box)

Related

Having several problems clicking a button with selenium in Google Chrome

I'm trying to click a button but its being really difficult. More precise, I want to do it for several buttons. I have tried several options but none is working properly. Here is the html code for the button:
<button class="rlg-trade__action rlg-trade__bump --bump " type="button" data-alias="bd520a66-cc88-4af8-ba92-30111bbdbd02" data-preventtext="Bumping…">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g style="stroke-linecap:round;stroke-linejoin:round;stroke:#6a717f;fill:none;stroke-miterlimit:10" transform="translate(.5 .5)"><path d="m12 23v-13"></path><path d="m16 14-4-4-4 4"></path><g stroke="#6a717f"><path d="m4 17h-3v-16h22v16h-3"></path><path d="m1 5h22"></path></g></g></svg>
<span>Bump</span>
</button>
And here is the code for scrapping:
trades_column = self.driver.find_element_by_css_selector('.rlg-trading__intersect') #Section where all trades are listed
trades_list = trades_column.find_elements(By.CLASS_NAME,'rlg-trade') #Search each trade element, all of them include the bump button posted above.
for trades in trades_list:
bump = trades.find_element_by_css_selector('.rlg-trade__action.rlg-trade__bump.--bump').click()
print('Trade bumped successfully!')
time.sleep(1)
self.driver.find_element_by_css_selector('i.fa').click() #This is a click in the page to exit a box that appear after the click.
Have tried by xpath, not working either. Any help would be appreciated.
Output error: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"button.rlg-trade__action.rlg-trade__bump.--bump"}
<div class="rlg-trade" data-i="0"> its every item in the trade list section rlg-trading__intersect.
<div class="col-3-3 rlg-trading__intersect">
<div class="rlg-trade" data-i="0" style="">
<header class="rlg-trade__header
">
<a href="/player/isaacdl" class="rlg-trade__user">
<div class="rlg-trade__avatar"><img loading="lazy" class="rlg-trade__avatarimage" src="/content/media/users/avatar/128px/b35468f2331659986325.png" alt="isaacdl"></div>
<div class="rlg-trade__meta">
<div class="rlg-trade__username">
isaacdl
</div>
<span class="rlg-trade__info">
<span class="rlg-trade__time">
<span>5 hours ago</span>
<span>5 hours, 20 minutes, 40 seconds ago</span>
</span>
<span class="rlg-trade__delinfo">·
This trade will be deleted in <strong class="rlg-trade__timeleft">14 days</strong> if you don't bump it.</span>
</span>
</div>
</a>
<div class="rlg-trade__platforms">
<a target="_blank" rel="noopener" class="rlg-trade__platform" style="order: 100;" href="https://steamcommunity.com/profiles/76561198120028164" onclick="event.preventDefault();phishingAware('https://steamcommunity.com/profiles/76561198120028164');">
<img class="rlg-trade__platformlogo" src="https://static.rocket-league.com/assets/b81c8860521ff08c3d8194c2eca3491c1b158f13/images/logos/windowspc_black.svg" alt="Windows PC">
<div class="rlg-trade__platformname">
<span>Add on
Steam
</span>
<span>
auchan </span>
</div>
</a>
</div>
</header>
<div class="rlg-trade__content">
<div class="rlg-trade__labels">
<div class="rlg-trade__haslabel">
Has
</div>
<div class="rlg-trade__wantslabel">
Wants
</div>
</div>
<div class="rlg-trade__items">
<div class="rlg-trade__itemshas ">
<div class="rlg-item --very-rare --hover">
<div class="rlg-item__gradient --very-rare"></div>
<img loading="lazy" class="rlg-item__image" src="/content/media/items/avatar/220px/a67e907fb81451699877.png" alt="Cristiano ">
<div class="rlg-item__text">
<h2 class="rlg-item__name">Cristiano</h2>
</div>
<div class="rlg-item-links">
<a class="rlg-btn-primary --small" href="/items/wheels/cristiano">Item details</a>
<a class="rlg-btn-secondary --small" href="/trading/?filterItem=148&filterCertification=0&filterPaint=0&filterPlatform=0&filterItemType=1">Find trades</a>
</div>
</div>
<div class="rlg-item --very-rare --hover">
<div class="rlg-item__gradient --very-rare"></div>
<img loading="lazy" class="rlg-item__image" src="/content/media/items/avatar/220px/a67e907fb81451699877.png" alt="Cristiano ">
<div class="rlg-item__text">
<h2 class="rlg-item__name">Cristiano</h2>
</div>
<div class="rlg-item-links">
<a class="rlg-btn-primary --small" href="/items/wheels/cristiano">Item details</a>
<a class="rlg-btn-secondary --small" href="/trading/?filterItem=148&filterCertification=0&filterPaint=0&filterPlatform=0&filterItemType=1">Find trades</a>
</div>
</div>
</div>
<div class="rlg-trade__wantslabel rlg-trade__wantslabelalt">
Wants
</div>
<div class="rlg-trade__itemswants ">
<div class="rlg-item --premium --hover">
<div class="rlg-item__gradient --premium"></div>
<img loading="lazy" class="rlg-item__image" src="/content/media/items/avatar/220px/da6ecd87091575484054.png" alt="Credits ">
<div class="rlg-item__text">
<h2 class="rlg-item__name">Credits</h2>
</div>
<div class="rlg-item__quantity --quantity-80 --premium">
80 </div>
<div class="rlg-item-links">
<a class="rlg-btn-primary --small" href="/items/misc/credits">Item details</a>
<a class="rlg-btn-secondary --small" href="/trading/?filterItem=2615&filterCertification=0&filterPaint=0&filterPlatform=0&filterItemType=1">Find trades</a>
</div>
</div>
<div class="rlg-item --premium --hover">
<div class="rlg-item__gradient --premium"></div>
<img loading="lazy" class="rlg-item__image" src="/content/media/items/avatar/220px/da6ecd87091575484054.png" alt="Credits ">
<div class="rlg-item__text">
<h2 class="rlg-item__name">Credits</h2>
</div>
<div class="rlg-item__quantity --quantity-80 --premium">
80 </div>
<div class="rlg-item-links">
<a class="rlg-btn-primary --small" href="/items/misc/credits">Item details</a>
<a class="rlg-btn-secondary --small" href="/trading/?filterItem=2615&filterCertification=0&filterPaint=0&filterPlatform=0&filterItemType=1">Find trades</a>
</div>
</div>
</div>
</div>
</div>
<div class="rlg-trade__actions">
<button class="rlg-trade__action rlg-trade__bump --bump " type="button" data-alias="bd520a66-cc88-4af8-ba92-30111bbdbd02" data-preventtext="Bumping…">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g style="stroke-linecap:round;stroke-linejoin:round;stroke:#6a717f;fill:none;stroke-miterlimit:10" transform="translate(.5 .5)"><path d="m12 23v-13"></path><path d="m16 14-4-4-4 4"></path><g stroke="#6a717f"><path d="m4 17h-3v-16h22v16h-3"></path><path d="m1 5h22"></path></g></g></svg>
<span>Bump</span>
</button>
<a class="rlg-trade__action rlg-trade__edit --edit" href="/trade/edit?trade=bd520a66-cc88-4af8-ba92-30111bbdbd02">
<svg viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke="#6a717f" stroke-linecap="round" stroke-linejoin="round"><path d="m9.5.5 2 2-5 5-3 1 1-3z"></path><path d="m10.5 8.5v2a1 1 0 0 1 -1 1h-8a1 1 0 0 1 -1-1v-8a1 1 0 0 1 1-1h2" stroke="#6a717f"></path></g></svg>
<span>Edit trade</span>
</a>
<a class="rlg-trade__action rlg-trade__disable --disable" href="/functions/disableTrade.php?trade=bd520a66-cc88-4af8-ba92-30111bbdbd02" onclick="return confirm('Are you sure you want to disable this trade? This trade will be permanently removed.')">
<svg height="20" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><g style="stroke-linecap:round;stroke-linejoin:round;stroke-width:1.2;fill:none;stroke:#6a717f;stroke-miterlimit:10"><path d="m20.3 4.7-15.6 15.6"></path><circle cx="12.5" cy="12.5" r="11"></circle></g></svg> <span>Disable trade</span>
</a>
<a href="/trade/bd520a66-cc88-4af8-ba92-30111bbdbd02" class="rlg-trade__action --comments">
<svg viewBox="0 0 18 21" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke="#545454" stroke-linecap="round" stroke-linejoin="round"><path d="m1.421053 1.421053h15.157895v18.526316h-15.157895z"></path><path d="m4.789474 4.789474h8.421053v5.052632h-8.421053z"></path><path d="m4.789474 13.210526h8.421052"></path><path d="m4.789474 16.578947h8.421052"></path></g></svg>
<span>Comments</span>
</a>
</div>
<div class="rlg-trade__note">
Have 2x of them. Please fast. </div>
<button class="rlg-trade__noteexpand" style="display: none;">Show full trade description</button>
</div>
<div class="rlg-trade rlg-trade-placeholder" data-i="1" style="height: 323px; box-shadow: none;"></div>
<div class="rlg-trade rlg-trade-placeholder" data-i="2" style="height: 323px; box-shadow: none;"></div>
<div class="rlg-trade rlg-trade-placeholder" data-i="3" style="height: 323px; box-shadow: none;"></div>
</div>
Try use following xpath to click on the element.
for trades in trades_list:
trades.find_element(By.XPATH,'.//button[.//span[text()="Bump"]]').click()
print('Trade bumped successfully!')
time.sleep(1)

unable to find correct XPATH for selenium drag and drop

I'm building a python script to help upload to beatstars quicker, however I'm having an issue locating the correct element to click on. As well as finding the XPATH. As of now I have no issue opening chrome, moving to beatstars, and pressing the upload button, however once doing so a modal pops up with a drag and drop section:
The issue I have is with locating the correct button to click to open browse or if there's a better way like just copying the file directly into the section. This is the html for this.
<mat-dialog-container
tabindex="-1"
aria-modal="true"
class="mat-dialog-container ng-tns-c25-86 ng-trigger ng-trigger-dialogContainer ng-star-inserted"
id="mat-dialog-5"
role="dialog"
style="transform: none"
><ng-component _nghost-jyk-c105="" class="ng-star-inserted"
><mat-dialog-content
_ngcontent-jyk-c105=""
class="mat-dialog-content upload-dialog-content"
><div _ngcontent-jyk-c105="" class="header">
<h3 _ngcontent-jyk-c105="">Single file upload</h3>
<button _ngcontent-jyk-c105="" class="ng-star-inserted" style="">
<i
_ngcontent-jyk-c105=""
class="vb-icon-close-m-regular-solid"
></i></button
><!---->
</div>
<mat-tab-group
_ngcontent-jyk-c105=""
class="mat-tab-group mat-primary ng-star-inserted"
style=""
><mat-tab-header class="mat-tab-header"
><div
aria-hidden="true"
mat-ripple=""
class="mat-ripple mat-tab-header-pagination mat-tab-header-pagination-before mat-elevation-z4 mat-tab-header-pagination-disabled"
>
<div class="mat-tab-header-pagination-chevron"></div>
</div>
<div class="mat-tab-label-container">
<div
role="tablist"
class="mat-tab-list"
style="transform: translateX(0px)"
>
<div class="mat-tab-labels">
<div
role="tab"
mattablabelwrapper=""
mat-ripple=""
cdkmonitorelementfocus=""
class="mat-ripple mat-tab-label mat-focus-indicator mat-tab-label-active ng-star-inserted"
id="mat-tab-label-4-0"
tabindex="0"
aria-posinset="1"
aria-setsize="4"
aria-controls="mat-tab-content-4-0"
aria-selected="true"
aria-disabled="false"
>
<div class="mat-tab-label-content">
<i
_ngcontent-jyk-c105=""
class="vb-icon-cloud-upload-file-m-regular ng-star-inserted"
></i>
Upload
<!----><!----><!---->
</div>
</div>
<div
role="tab"
mattablabelwrapper=""
mat-ripple=""
cdkmonitorelementfocus=""
class="mat-ripple mat-tab-label mat-focus-indicator ng-star-inserted"
id="mat-tab-label-4-1"
tabindex="-1"
aria-posinset="2"
aria-setsize="4"
aria-controls="mat-tab-content-4-1"
aria-selected="false"
aria-disabled="false"
>
<div class="mat-tab-label-content">
<i
_ngcontent-jyk-c105=""
class="vb-icon-drive-m-regular-solid ng-star-inserted"
></i>
Google Drive
<!----><!----><!---->
</div>
</div>
<div
role="tab"
mattablabelwrapper=""
mat-ripple=""
cdkmonitorelementfocus=""
class="mat-ripple mat-tab-label mat-focus-indicator ng-star-inserted"
id="mat-tab-label-4-2"
tabindex="-1"
aria-posinset="3"
aria-setsize="4"
aria-controls="mat-tab-content-4-2"
aria-selected="false"
aria-disabled="false"
>
<div class="mat-tab-label-content">
<i
_ngcontent-jyk-c105=""
class="vb-icon-dropbox-m-regular-solid ng-star-inserted"
></i>
Dropbox
<!----><!----><!---->
</div>
</div>
<div
role="tab"
mattablabelwrapper=""
mat-ripple=""
cdkmonitorelementfocus=""
class="mat-ripple mat-tab-label mat-focus-indicator ng-star-inserted"
id="mat-tab-label-4-3"
tabindex="-1"
aria-posinset="4"
aria-setsize="4"
aria-controls="mat-tab-content-4-3"
aria-selected="false"
aria-disabled="false"
>
<div class="mat-tab-label-content">
<i
_ngcontent-jyk-c105=""
class="vb-icon-link-m-regular-solid ng-star-inserted"
></i>
Import URL
<!----><!----><!---->
</div>
</div>
<!---->
</div>
<mat-ink-bar
class="mat-ink-bar"
style="visibility: visible; left: 0px; width: 160px"
></mat-ink-bar>
</div>
</div>
<div
aria-hidden="true"
mat-ripple=""
class="mat-ripple mat-tab-header-pagination mat-tab-header-pagination-after mat-elevation-z4 mat-tab-header-pagination-disabled"
>
<div class="mat-tab-header-pagination-chevron"></div></div
></mat-tab-header>
<div class="mat-tab-body-wrapper">
<mat-tab-body
role="tabpanel"
class="mat-tab-body ng-tns-c115-87 mat-tab-body-active ng-star-inserted"
id="mat-tab-content-4-0"
aria-labelledby="mat-tab-label-4-0"
><div
cdkscrollable=""
class="mat-tab-body-content ng-tns-c115-87 ng-trigger ng-trigger-translateTab"
style="transform: none"
>
<!----><!----><!----><!----><!----><!----><!---->
<div
_ngcontent-jyk-c105=""
class="step ng-star-inserted"
style=""
>
<div _ngcontent-jyk-c105="" class="drag-drop-container">
<div _ngcontent-jyk-c105="" class="drag-drop-message">
<div _ngcontent-jyk-c105="" class="icons">
<i
_ngcontent-jyk-c105=""
class="vb-icon-cloud-upload-file-m-regular"
></i>
</div>
<h4 _ngcontent-jyk-c105="">
Drag & Drop, or <a _ngcontent-jyk-c105=""> Browse </a>
</h4>
<label
_ngcontent-jyk-c105=""
class="file-type ng-star-inserted"
><!----><span
_ngcontent-jyk-c105=""
class="ng-star-inserted"
>
.mp3 or .wav </span
><!----><!----><!----><!----><!----><!----><!----><!----></label
><!---->
</div>
<div
_ngcontent-jyk-c105=""
id="uppy-drag-drop"
data-qa="uppy_drag_drop"
class="uppy-box"
>
<button
type="button"
class="uppy-Root uppy-u-reset uppy-DragDrop-container uppy-DragDrop--isDragDropSupported"
style="width: 100%; height: 100%"
>
<input
class="uppy-DragDrop-input"
type="file"
hidden=""
name="files[]"
multiple=""
accept="audio/mp3,audio/x-mp3,audio/mpeg,audio/mpeg3,audio/x-mpeg-3,audio/wav,audio/x-wav,audio/wave,audio/x-wave,audio/vnd.wave,application/octet-stream"
/>
<div class="uppy-DragDrop-inner">
<svg
aria-hidden="true"
focusable="false"
class="uppy-c-icon uppy-DragDrop-arrow"
width="16"
height="16"
viewBox="0 0 16 16"
>
<path
d="M11 10V0H5v10H2l6 6 6-6h-3zm0 0"
fillRule="evenodd"
></path>
</svg>
<div class="uppy-DragDrop-label">
Drop files here or
<span class="uppy-DragDrop-browse">browse</span>
</div>
<span class="uppy-DragDrop-note"></span>
</div>
</button>
</div>
</div>
<div _ngcontent-jyk-c105="" class="my-files ng-star-inserted">
<label _ngcontent-jyk-c105=""> My files </label
><bs-secondary-uploaded-files
_ngcontent-jyk-c105=""
_nghost-jyk-c136=""
class="ng-star-inserted"
style=""
><div _ngcontent-jyk-c136="" class="uploaded-files">
<ul
_ngcontent-jyk-c136=""
class="files-uploaded ng-star-inserted"
>
<li
_ngcontent-jyk-c136=""
id="row-0"
class="ng-star-inserted"
>
<div _ngcontent-jyk-c136="" class="left">
<div _ngcontent-jyk-c136="" class="file-type-icon">
<i
_ngcontent-jyk-c136=""
class="icon-music-4"
></i>
</div>
<div _ngcontent-jyk-c136="" class="file-info">
<span _ngcontent-jyk-c136="" class="file-name"
>j-cole-type-beat</span
>
<div
_ngcontent-jyk-c136=""
class="secondary-info ng-star-inserted"
>
<span _ngcontent-jyk-c136="">26.00 MB</span
><span
_ngcontent-jyk-c136=""
class="ng-star-inserted"
> ∙ </span
><!----><span _ngcontent-jyk-c136=""
>Sep 2, 2022, 6:05 PM</span
>
</div>
<!---->
</div>
</div>
<div _ngcontent-jyk-c136="" class="right">
<bs-menu-more-options
_ngcontent-jyk-c136=""
class="menu-more-options"
_nghost-jyk-c93=""
><div
_ngcontent-jyk-c93=""
aria-haspopup="true"
class="mat-menu-trigger wrapper-button"
style="margin-left: 0px; margin-right: 0px"
>
<button
_ngcontent-jyk-c93=""
mat-icon-button=""
class="mat-focus-indicator mat-tooltip-trigger mat-icon-button mat-button-base ng-star-inserted"
aria-describedby="cdk-describedby-message-9"
cdk-describedby-host=""
>
<span class="mat-button-wrapper"
><i
_ngcontent-jyk-c93=""
class="icon-dots ng-star-inserted"
></i
><!----></span
><span
matripple=""
class="mat-ripple mat-button-ripple mat-button-ripple-round"
></span
><span
class="mat-button-focus-overlay"
></span></button
><!----><!---->
</div>
<!----><mat-menu
_ngcontent-jyk-c93=""
class="ng-star-inserted"
><!----></mat-menu
><!----><!----></bs-menu-more-options
><bs-square-button
_ngcontent-jyk-c136=""
buttontype="button"
class="btn-select ng-star-inserted"
_nghost-jyk-c103=""
><button
_ngcontent-jyk-c103=""
bssquarebuttonfocus=""
type="button"
class="action-element primary ng-star-inserted"
>
Select
<!----></button
><!----><!----><!----></bs-square-button
><!----><!---->
</div>
<div
_ngcontent-jyk-c136=""
class="border-bottom"
></div>
</li>
<li
_ngcontent-jyk-c136=""
id="row-1"
class="ng-star-inserted"
>
<div _ngcontent-jyk-c136="" class="left">
<div _ngcontent-jyk-c136="" class="file-type-icon">
<i
_ngcontent-jyk-c136=""
class="icon-music-4"
></i>
</div>
<div _ngcontent-jyk-c136="" class="file-info">
<span _ngcontent-jyk-c136="" class="file-name"
>island-girl</span
>
<div
_ngcontent-jyk-c136=""
class="secondary-info ng-star-inserted"
>
<span _ngcontent-jyk-c136="">27.10 MB</span
><span
_ngcontent-jyk-c136=""
class="ng-star-inserted"
> ∙ </span
><!----><span _ngcontent-jyk-c136=""
>Aug 31, 2022, 10:47 PM</span
>
</div>
<!---->
</div>
</div>
<div _ngcontent-jyk-c136="" class="right">
<bs-menu-more-options
_ngcontent-jyk-c136=""
class="menu-more-options"
_nghost-jyk-c93=""
><div
_ngcontent-jyk-c93=""
aria-haspopup="true"
class="mat-menu-trigger wrapper-button"
style="margin-left: 0px; margin-right: 0px"
>
<button
_ngcontent-jyk-c93=""
mat-icon-button=""
class="mat-focus-indicator mat-tooltip-trigger mat-icon-button mat-button-base ng-star-inserted"
aria-describedby="cdk-describedby-message-9"
cdk-describedby-host=""
>
<span class="mat-button-wrapper"
><i
_ngcontent-jyk-c93=""
class="icon-dots ng-star-inserted"
></i
><!----></span
><span
matripple=""
class="mat-ripple mat-button-ripple mat-button-ripple-round"
></span
><span
class="mat-button-focus-overlay"
></span></button
><!----><!---->
</div>
<!----><mat-menu
_ngcontent-jyk-c93=""
class="ng-star-inserted"
><!----></mat-menu
><!----><!----></bs-menu-more-options
><bs-square-button
_ngcontent-jyk-c136=""
buttontype="button"
class="btn-select ng-star-inserted"
_nghost-jyk-c103=""
><button
_ngcontent-jyk-c103=""
bssquarebuttonfocus=""
type="button"
class="action-element primary ng-star-inserted"
>
Select
<!----></button
><!----><!----><!----></bs-square-button
><!----><!---->
</div>
<div
_ngcontent-jyk-c136=""
class="border-bottom"
></div>
</li>
<li
_ngcontent-jyk-c136=""
id="row-2"
class="ng-star-inserted"
>
<div _ngcontent-jyk-c136="" class="left">
<div _ngcontent-jyk-c136="" class="file-type-icon">
<i
_ngcontent-jyk-c136=""
class="icon-music-4"
></i>
</div>
<div _ngcontent-jyk-c136="" class="file-info">
<span _ngcontent-jyk-c136="" class="file-name"
>island-girl</span
>
<div
_ngcontent-jyk-c136=""
class="secondary-info ng-star-inserted"
>
<span _ngcontent-jyk-c136="">3.69 MB</span
><span
_ngcontent-jyk-c136=""
class="ng-star-inserted"
> ∙ </span
><!----><span _ngcontent-jyk-c136=""
>Aug 31, 2022, 10:47 PM</span
>
</div>
<!---->
</div>
</div>
<div _ngcontent-jyk-c136="" class="right">
<bs-menu-more-options
_ngcontent-jyk-c136=""
class="menu-more-options"
_nghost-jyk-c93=""
><div
_ngcontent-jyk-c93=""
aria-haspopup="true"
class="mat-menu-trigger wrapper-button"
style="margin-left: 0px; margin-right: 0px"
>
<button
_ngcontent-jyk-c93=""
mat-icon-button=""
class="mat-focus-indicator mat-tooltip-trigger mat-icon-button mat-button-base ng-star-inserted"
aria-describedby="cdk-describedby-message-9"
cdk-describedby-host=""
>
<span class="mat-button-wrapper"
><i
_ngcontent-jyk-c93=""
class="icon-dots ng-star-inserted"
></i
><!----></span
><span
matripple=""
class="mat-ripple mat-button-ripple mat-button-ripple-round"
></span
><span
class="mat-button-focus-overlay"
></span></button
><!----><!---->
</div>
<!----><mat-menu
_ngcontent-jyk-c93=""
class="ng-star-inserted"
><!----></mat-menu
><!----><!----></bs-menu-more-options
><bs-square-button
_ngcontent-jyk-c136=""
buttontype="button"
class="btn-select ng-star-inserted"
_nghost-jyk-c103=""
><button
_ngcontent-jyk-c103=""
bssquarebuttonfocus=""
type="button"
class="action-element primary ng-star-inserted"
>
Select
<!----></button
><!----><!----><!----></bs-square-button
><!----><!---->
</div>
<div
_ngcontent-jyk-c136=""
class="border-bottom"
></div>
</li>
<!---->
</ul>
<!----><!---->
</div></bs-secondary-uploaded-files
><!----><!---->
</div>
<!---->
</div>
<!----><!----><!----><!----><!---->
</div></mat-tab-body
><mat-tab-body
role="tabpanel"
class="mat-tab-body ng-tns-c115-88 ng-star-inserted"
id="mat-tab-content-4-1"
aria-labelledby="mat-tab-label-4-1"
><div
cdkscrollable=""
class="mat-tab-body-content ng-tns-c115-88 ng-trigger ng-trigger-translateTab"
style="transform: translate3d(100%, 0px, 0px); min-height: 1px"
>
<!---->
</div></mat-tab-body
><mat-tab-body
role="tabpanel"
class="mat-tab-body ng-tns-c115-89 ng-star-inserted"
id="mat-tab-content-4-2"
aria-labelledby="mat-tab-label-4-2"
><div
cdkscrollable=""
class="mat-tab-body-content ng-tns-c115-89 ng-trigger ng-trigger-translateTab"
style="transform: translate3d(100%, 0px, 0px); min-height: 1px"
>
<!---->
</div></mat-tab-body
><mat-tab-body
role="tabpanel"
class="mat-tab-body ng-tns-c115-90 ng-star-inserted"
id="mat-tab-content-4-3"
aria-labelledby="mat-tab-label-4-3"
><div
cdkscrollable=""
class="mat-tab-body-content ng-tns-c115-90 ng-trigger ng-trigger-translateTab"
style="transform: translate3d(100%, 0px, 0px); min-height: 1px"
>
<!---->
</div></mat-tab-body
><!---->
</div></mat-tab-group
><!----><!----><!----><!----></mat-dialog-content
></ng-component
><!----></mat-dialog-container
>
I'm new to selenium and can't find the write thing to try and click on:
This is my code:
browser = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver')
browser.get(url)
wait = WebDriverWait(browser, 20)
email = browser.find_element(By.ID, "oath-email").send_keys(username, Keys.ENTER)
password = wait.until(EC.presence_of_element_located((By.ID, "userPassword"))).send_keys(password, Keys.ENTER)
new_track = wait.until(EC.presence_of_element_located((By.XPATH, "/html/body/studio-root/div/ng-component/studio-header/header/div/div/bs-square-button/button"))).click()
upload = wait.until(EC.presence_of_element_located((By.XPATH, '/html/body/studio-root/div/ng-component/studio-page-container/div/form/studio-inventory-form-holder/div/studio-panel/div/mat-tab-group/div/mat-tab-body[1]/div/studio-wrapper-track-files/studio-form-files/div/section[1]/div/studio-form-file-box/div/div/div[2]/bs-upload-button/bs-universal-upload-button/div/div/bs-square-button/button'))).click()
drag_and_drop = wait.until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[4]/div[8]/div/mat-dialog-container/ng-component/mat-dialog-content/mat-tab-group/div/mat-tab-body[1]/div/div/div[1]/div[2]/button'))).click()

How to click on dynamic button using selenium Python?

I am using Selenium Python and trying to access one of the dynamic created buttons which have same names and no ID.
By.XPATH and By.CLASS_NAME not working here. Any suggestions how can I click on this.This is the button I want to click
This is how I am trying
btn=WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, '//*[#id="BsGnbProv"]/div[1]/div[13]/div[2]/div[3]/div[3]/button[2]')))
This is xPath
//*[#id="BsGnbProv"]/div[1]/div[13]/div[2]/div[3]/div[3]/button[2]
This is Button element details
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable:
false, click: ViewNetworkFuncModal, visible: $root.IsReadOnly"
style="white-space: normal;">
<span class="mr-1 fa fa-edit">
</span>
<span>View Configuration</span>
</button>
This is the html of this div containing all buttons
<div data-bind="visible: GeneralProperties.NfCount() > 0, css: { 'bs-inactive': $root.IsInactive }" data-csv-category="Network Function Properties" class="card m-1 flex-shrink-0 ns-toggle"><div class="card-header"><label>Network Function Properties</label></div>
<div class="overflow-auto card-body ns-width-md">
<div class="form-group ns-width-md">
<div class="col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label class="d-block text-truncate property-label text-dark" data-placement="top" data-toggle="tooltip" style="text-decoration: underline;" title="" data-original-title="Function Type">Function Type</label>
</div>
<div class="col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label class="d-block text-truncate property-label text-dark" data-placement="top" data-toggle="tooltip" style="text-decoration: underline;" title="" data-original-title="Managed Element ID">Managed Element ID</label>
</div>
</div>
<!-- ko with: GeneralProperties.PuProperties -->
<!-- ko foreach: NetworkFunctionDetailsList -->
<div style="min-width: 480px;" class="form-group ">
<div class="d-inline-flex align-items-center col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label data-bind="text: NfTypeDesc, attr: { title: NfTypeDesc }" data-csv-label="Function Type" class="property-label d-block text-truncate text-dark" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="xPU">xPU</label>
</div>
<div class="d-inline-flex align-items-center col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label data-bind="text: Id, attr: { title: Id }" data-csv-label="Managed Element ID" class="property-label d-block text-truncate text-dark" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="EAB8620065F0">EAB8620065F0</label>
</div>
<div class="col col-12 col-sm-4 col-md-4 col-lg-4 col-xl-4">
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable: $root.IsReadOnly, click: LoadNetworkFuncModal, visible: !$root.IsReadOnly()" style="white-space: normal; display: none;" disabled="">
<span class="mr-1 fa fa-edit"></span>
<span>Edit Configuration</span></button>
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable: false, click: ViewNetworkFuncModal, visible: $root.IsReadOnly" style="white-space: normal;">
<span class="mr-1 fa fa-edit"></span>
<span>View Configuration</span></button>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko with: GeneralProperties.CuCpProperties -->
<!-- ko foreach: NetworkFunctionDetailsList -->
<div style="min-width: 480px;" class="form-group ">
<div class="d-inline-flex align-items-center col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label data-bind="text: NfTypeDesc, attr: { title: NfTypeDesc }" data-csv-label="Function Type" class="property-label d-block text-truncate text-dark" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="CU-CP">CU-CP</label>
</div>
<div class="d-inline-flex align-items-center col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label data-bind="text: Id, attr: { title: Id }" data-csv-label="Managed Element ID" class="property-label d-block text-truncate text-dark" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="CUCP-at2200-eab8620065f0-1">CUCP-at2200-eab8620065f0-1</label>
</div>
<div class="col col-12 col-sm-4 col-md-4 col-lg-4 col-xl-4">
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable: $root.IsReadOnly, click: LoadNetworkFuncModal, visible: !$root.IsReadOnly()" style="white-space: normal; display: none;" disabled="">
<span class="mr-1 fa fa-edit"></span>
<span>Edit Configuration</span></button>
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable: false, click: ViewNetworkFuncModal, visible: $root.IsReadOnly" style="white-space: normal;">
<span class="mr-1 fa fa-edit"></span>
<span>View Configuration</span></button>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko with: GeneralProperties.CuUpProperties -->
<!-- ko foreach: NetworkFunctionDetailsList -->
<div style="min-width: 480px;" class="form-group ">
<div class="d-inline-flex align-items-center col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label data-bind="text: NfTypeDesc, attr: { title: NfTypeDesc }" data-csv-label="Function Type" class="property-label d-block text-truncate text-dark" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="CU-UP">CU-UP</label>
</div>
<div class="d-inline-flex align-items-center col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label data-bind="text: Id, attr: { title: Id }" data-csv-label="Managed Element ID" class="property-label d-block text-truncate text-dark" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="CUUP-at2200-eab8620065f0-1">CUUP-at2200-eab8620065f0-1</label>
</div>
<div class="col col-12 col-sm-4 col-md-4 col-lg-4 col-xl-4">
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable: $root.IsReadOnly, click: LoadNetworkFuncModal, visible: !$root.IsReadOnly()" style="white-space: normal; display: none;" disabled="">
<span class="mr-1 fa fa-edit"></span>
<span>Edit Configuration</span></button>
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable: false, click: ViewNetworkFuncModal, visible: $root.IsReadOnly" style="white-space: normal;">
<span class="mr-1 fa fa-edit"></span>
<span>View Configuration</span></button>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko with: GeneralProperties.DuProperties -->
<!-- ko foreach: NetworkFunctionDetailsList -->
<div style="min-width: 480px;" class="form-group ">
<div class="d-inline-flex align-items-center col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label data-bind="text: NfTypeDesc, attr: { title: NfTypeDesc }" data-csv-label="Function Type" class="property-label d-block text-truncate text-dark" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="DU">DU</label>
</div>
<div class="d-inline-flex align-items-center col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label data-bind="text: Id, attr: { title: Id }" data-csv-label="Managed Element ID" class="property-label d-block text-truncate text-dark" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="DU-at2200-eab8620065f0-1">DU-at2200-eab8620065f0-1</label>
</div>
<div class="col col-12 col-sm-4 col-md-4 col-lg-4 col-xl-4">
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable: $root.IsReadOnly, click: LoadNetworkFuncModal, visible: !$root.IsReadOnly()" style="white-space: normal; display: none;" disabled="">
<span class="mr-1 fa fa-edit"></span>
<span>Edit Configuration</span></button>
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable: false, click: ViewNetworkFuncModal, visible: $root.IsReadOnly" style="white-space: normal;">
<span class="mr-1 fa fa-edit"></span>
<span>View Configuration</span></button>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko with: GeneralProperties.RuProperties -->
<!-- ko foreach: NetworkFunctionDetailsList -->
<div style="min-width: 480px;" class="form-group ">
<div class="d-inline-flex align-items-center col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label data-bind="text: NfTypeDesc, attr: { title: NfTypeDesc }" data-csv-label="Function Type" class="property-label d-block text-truncate text-dark" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="RU">RU</label>
</div>
<div class="d-inline-flex align-items-center col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3">
<label data-bind="text: Id, attr: { title: Id }" data-csv-label="Managed Element ID" class="property-label d-block text-truncate text-dark" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="RU-at2200-eab8620065f0-1">RU-at2200-eab8620065f0-1</label>
</div>
<div class="col col-12 col-sm-4 col-md-4 col-lg-4 col-xl-4">
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable: $root.IsReadOnly, click: LoadNetworkFuncModal, visible: !$root.IsReadOnly()" style="white-space: normal; display: none;" disabled="">
<span class="mr-1 fa fa-edit"></span>
<span>Edit Configuration</span></button>
<button class="w-100 btn btn-light btn-sm mr-1" data-bind="disable: false, click: ViewNetworkFuncModal, visible: $root.IsReadOnly" style="white-space: normal;">
<span class="mr-1 fa fa-edit"></span>
<span>View Configuration</span></button>
</div>
</div>
<!-- /ko -->
<!-- /ko -->
</div>
</div>
#Atif, thanks for the detail HTML. Can you try the following XPath:
//button/span[text()='View Configuration']
This will give you the five buttons and then you can take action accordingly. I tried this and it is working fine.

Automate form filling whose field is powered by Google with Python

I'm trying to get data from a csv and input in fields of a form with selenium. I managed to do most of it, however the first field which is an address, to be recognized by the form I have to click on the option that appears in a box powered by Google.
Website of form: (Must have registration)
https://indicaai.quintoandar.com.br/
This is what show powered by google when I write something
Any tips on how to resolve this?
Edit:
<fieldset>
<span class="sc-bdVaJa Ongdx"><span>Insira o endereço do imóvel e os dados do proprietário para indicar</span></span>
<div data-testid="search-address-container" class="AddressWrapper-cBPhHQ jhZitp">
<div class="SearchBarInnerWrapper-gXtreI jrzXsr">
<div>
<div class="MuiFormControl-root MuiTextField-root TextValidatorWrapper-jlrQgm fNMjqh MuiFormControl-marginDense MuiFormControl-fullWidth" theme="[object Object]" maxlength="100">
<label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-marginDense Mui-focused Mui-focused" data-shrink="true">Rua*</label>
<div class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth Mui-focused Mui-focused MuiInputBase-formControl MuiInput-formControl MuiInputBase-marginDense">
<input aria-invalid="false" autocomplete="off" name="googleApiAddress" placeholder="Exemplo: Av. Paulista, 235" type="text" maxlength="100" class="MuiInputBase-input MuiInput-input MuiInputBase-inputMarginDense MuiInput-inputMarginDense">
</div>
</div>
<div class="AdditionalInfo-dmbwFQ TvjqL"></div>
</div>
</div>
<div class="MuiGrid-root MuiGrid-container">
<div class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6">
<div>
<div class="MuiFormControl-root MuiTextField-root TextValidatorWrapper-jlrQgm fNMjqh MuiFormControl-marginDense MuiFormControl-fullWidth" theme="[object Object]" maxlength="6">
<label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-marginDense" data-shrink="false">Número*</label>
<div class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-marginDense"><input aria-invalid="false" autocomplete="address-line2" name="housenumber" type="number" maxlength="6" class="MuiInputBase-input MuiInput-input MuiInputBase-inputMarginDense MuiInput-inputMarginDense"></div>
</div>
<div class="AdditionalInfo-dmbwFQ TvjqL"></div>
</div>
</div>
<div class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-6">
<div class="MuiBox-root jss357 sc-EHOje bYipDz">
<div>
<div class="MuiFormControl-root MuiTextField-root TextValidatorWrapper-jlrQgm fNMjqh MuiFormControl-marginDense MuiFormControl-fullWidth" theme="[object Object]" maxlength="100" data-testid="complement">
<label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-marginDense" data-shrink="false">Complemento</label>
<div class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-marginDense"><input aria-invalid="false" autocomplete="address-level4" name="complement" placeholder="Exemplo: Apto 42" type="text" maxlength="100" class="MuiInputBase-input MuiInput-input MuiInputBase-inputMarginDense MuiInput-inputMarginDense"></div>
</div>
<div class="AdditionalInfo-dmbwFQ TvjqL"></div>
</div>
</div>
</div>
<div class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12">
<div class="MuiBox-root jss358 sc-EHOje bYipDz">
<div class="MuiBox-root jss359 sc-EHOje bYipDz"><span class="sc-bdVaJa Ongdx"><span>Escolha o tipo de indicação:</span></span></div>
<div class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12">
<label class="MuiFormControlLabel-root" theme="[object Object]" color="primary">
<span class="MuiButtonBase-root MuiIconButton-root jss372 MuiCheckbox-root MuiCheckbox-colorPrimary colorPrimary sc-Rmtcm crdlgZ jss373 Mui-checked checked MuiIconButton-colorPrimary" aria-disabled="false" theme="[object Object]">
<span class="MuiIconButton-label">
<input class="jss375" name="forRent" type="checkbox" data-indeterminate="false" value="" checked="checked">
<svg class="MuiSvgIcon-root" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation">
<path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path>
</svg>
</span>
<span class="MuiTouchRipple-root"></span>
</span>
<span class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1"><span>Locação</span></span>
</label>
<label class="MuiFormControlLabel-root" theme="[object Object]" color="primary">
<span class="MuiButtonBase-root MuiIconButton-root jss372 MuiCheckbox-root MuiCheckbox-colorPrimary colorPrimary sc-Rmtcm crdlgZ jss373 Mui-checked checked MuiIconButton-colorPrimary" aria-disabled="false" theme="[object Object]">
<span class="MuiIconButton-label">
<input class="jss375" name="forSale" type="checkbox" data-indeterminate="false" value="" checked="checked">
<svg class="MuiSvgIcon-root" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation">
<path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path>
</svg>
</span>
<span class="MuiTouchRipple-root"></span>
</span>
<span class="MuiTypography-root MuiFormControlLabel-label MuiTypography-body1"><span>Venda</span></span>
</label>
</div>
</div>
</div>
</div>
</div>
</fieldset>
The field is the input with name ="googleApiAddress"
Illustrative image of the box that opens when typing something in the address field
Thanks for updating the details. According to the html and screenshot, once user starts typing an api request is sent and a matching address is suggested in the field. Can you try using sendKeys() to enter few words of the location and add a waituntil till the address suggestion pops-up? You can also throw in a sendKeys(Keys.ENTER) or sendKeys(Keys.RETURN) if address pop-up doesn't show up

Python Selenium Cannot find element using absolute xpath div

I have read over a days worth of webpages and stackoverflow posts and Ive gotten to the point where I "mostly" get a dynamic xPath to click on but its not clicking...
The objective is to dynamically remove a user from tradingview invite-only list for a private indicator. Clicking on Manage Access creates a popup where users are entered or removed. I can add users just fine however trying to click on the "x" next to a users name in the list is really difficult due to the nested divs being identical except for a custom data-username tag and span text value.
In short I can get the absolute xpath and I try to click on it but I get a cannot find element, which I know is not true.
Remove User arguments
unsubscribed - A list of users that is passed on to remove from TV
htmlsource - self.driver.page_source passed on to grab xpath for each user removal button.
Setup
Python 3.7.3+
Selenium
BeautifulSoup
ERROR MESSAGE
Traceback (most recent call last):
File "C:/Users/user/PycharmProjects/MG_TV_Users/tv_monitor.py", line 493, in <module>
start = TV(headless=False, browser='firefox',logintype='auto')
File "C:/Users/user/PycharmProjects/MG_TV_Users/tv_monitor.py", line 91, in __init__
self.update_tv(headless=headless, username=self.username, password=self.password, browser=self.browser)
File "C:/Users/user/PycharmProjects/MG_TV_Users/tv_monitor.py", line 120, in update_tv
self.manage_users(google_sheet_user_list)
File "C:/Users/user/PycharmProjects/MG_TV_Users/tv_monitor.py", line 354, in manage_users
self.removeusers(removeoldusers, htmlsource)
File "C:/Users/user/PycharmProjects/MG_TV_Users/tv_monitor.py", line 422, in removeusers
self.driver.find_element(By.XPATH,UNSUBSCRIBEUSER_BTN).click()
File "C:\Users\user\PycharmProjects\MG_TV_Users\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Users\user\PycharmProjects\MG_TV_Users\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\user\PycharmProjects\MG_TV_Users\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: /html/body/div[11]/div/div/div[2]/div/div[2]/div[2]/div[1]/div/div[1]/div[2]/div
FUNCTION TO REMOVE USERS
def removeusers(self, unsubscribed, htmlsource):
import re
tv_users = []
names = BS(htmlsource, features="html.parser")
result = names.find_all("div", {"class": "tv-manage-access-dialog__user-list-row"})
for res in result:
#print(res)
tv_users.append(res.text)
#print(elem)
tempsave = '/html/body/div[11]/div/div/div[2]/div/div[2]/div[2]/div[1]/div/div[1]/div[2]/div'
#PARENT DIV TO ALL USERS'tv-manage-access-dialog__user-list-body js-user-list'
tv_user_list = '/html/body/div[11]/div/div/div[2]/div/div[2]/div[2]/div[1]/div'
print('working on arviman')
#tempsave = '/html/body/div[11]/div/div/div[2]/div/div[2]/div[2]/div[1]/div/div[1]/div[2]/div'
for user in result:
if user.text in unsubscribed:
elem = names.find(string=re.compile(user.text))
UNSUBSCRIBED_ROOT_XPATH = self.xpath_soup(elem)
tostrip = '/div[1]/span' #GOES UP 2 ELEMENTS FROM SPAN NAME TO ROOT DIV OF USER.
toappend = '/div[2]/div' # LOCATION OF BUTTON 'X' TO REMOVE USER
if UNSUBSCRIBED_ROOT_XPATH.endswith(tostrip):
UNSUBSCRIBED_ROOT_XPATH = UNSUBSCRIBED_ROOT_XPATH.replace(tostrip, '')
UNSUBSCRIBEUSER_BTN = UNSUBSCRIBED_ROOT_XPATH + toappend
self.driver.find_element(By.XPATH,UNSUBSCRIBEUSER_BTN).click()
print(user.text , "REMOVED")
MANAGE ACCESS POP UP WINDOW - LIST
<div class="tv-dialog js-dialog tv-dialog--popup i-focused ui-draggable" tabindex="-1" style="width: calc(100% - 20px); max-width: 500px; top: 459px; left: 265px; z-index: 112;">
<div class="tv-dialog__section tv-dialog__section--title js-dialog__drag tv-dialog__grab ui-draggable-handle">
<div class="js-title-text tv-dialog__title">Manage Pine Script Access</div>
</div>
<div>
<div>
<div class="tv-dialog__section tv-manage-access-dialog__section js-search-placeholder">
<div class="tv-search-row">
<input class="tv-search-row__input js-input-control" type="text" name="q" value="" autocomplete="off" data-role="search" placeholder="Add user">
<span class="tv-search-row__input-reset i-hidden js-reset-button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 95.939 95.939" width="95.939" height="95.939">
<path d="M62.82 47.97l32.53-32.534a2 2 0 0 0 0-2.828L83.332.586a2 2 0 0 0-2.827 0L47.97 33.12 15.435.587c-.75-.75-2.078-.75-2.828 0L.587 12.607a2 2 0 0 0 0 2.83L33.12 47.97.588 80.504a2 2 0 0 0 0 2.828l12.02 12.02a1.997 1.997 0 0 0 2.83 0L47.97 62.818l32.535 32.535a2 2 0 0 0 2.827 0l12.02-12.02c.78-.783.78-2.05 0-2.83L62.82 47.97z"></path>
</svg>
</span>
<span class="tv-search-row__search-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18px" height="18px">
<path fill-rule="evenodd" d="M12.5 11h-.79l-.28-.27A6.47 6.47 0 0 0 13 6.5 6.5 6.5 0 1 0 6.5 13c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L17.49 16l-4.99-5zm-6 0C4.01 11 2 8.99 2 6.5S4.01 2 6.5 2 11 4.01 11 6.5 8.99 11 6.5 11z"></path>
</svg>
</span>
<div class="tv-username-hint-list js-hidden tv-username-hint-list--full-border" style="left: 0px; top: 100%; width: 65%; z-index: 100;"></div>
</div>
</div>
<div class="tv-dialog__section tv-manage-access-dialog__section">
<div class="tv-text tv-manage-access-dialog__user-list-header js-user-list-header">14 users have access</div>
<div class="tv-manage-access-dialog__user-list-container tv-dialog__scroll-wrap js-dialog__scroll-wrap wrapper-2KWBfDVB- sb-scroll-active" style="">
<div class="tv-dialog__scroll-wrap-inner js-user-list-attach" style="bottom: auto; top: 0px;">
<div class="tv-manage-access-dialog__user-list-body js-user-list">
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="snub-fighter">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%2890,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3ES%3C/text%3E%3C/svg%3E"><span>snub-fighter</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="KingThies_">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="https://s3.tradingview.com/userpics/1662357-tYZf.png"><span>KingThies_</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="Eniesee_ldk">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28312,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EE%3C/text%3E%3C/svg%3E"><span>Eniesee_ldk</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="sugarjun">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%289,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3ES%3C/text%3E%3C/svg%3E"><span>sugarjun</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="dijkie">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28144,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3ED%3C/text%3E%3C/svg%3E"><span>dijkie</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="PaulAdelaar">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%2884,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EP%3C/text%3E%3C/svg%3E"><span>PaulAdelaar</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="ladedimone">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28102,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EL%3C/text%3E%3C/svg%3E"><span>ladedimone</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="DK32100">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28339,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3ED%3C/text%3E%3C/svg%3E"><span>DK32100</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="Pisonglobal">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28126,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EP%3C/text%3E%3C/svg%3E"><span>Pisonglobal</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="whiteltr">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%2893,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EW%3C/text%3E%3C/svg%3E"><span>whiteltr</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="nerf_herder">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="https://s3.tradingview.com/userpics/3591101-9n72.png"><span>nerf_herder</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="Swaine123">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="https://s3.tradingview.com/userpics/4117895-HxYz.png"><span>Swaine123</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="Astynaxe">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="https://s3.tradingview.com/userpics/4207689-Eli2.png"><span>Astynaxe</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
<div class="tv-manage-access-dialog__user-list-row js-user-row" data-username="BassieWouters">
<div class="tv-manage-access-dialog__user-info-column js-userlink-popup"><img src="data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220,0,20,20%22%20width=%2239%22%20height=%2239%22%3E%3Crect%20height=%2220%22%20width=%2220%22%20fill=%22hsl%28120,25%25,50%25%29%22/%3E%3Ctext%20fill=%22white%22%20x=%2210%22%20y=%2214.8%22%20font-size=%2214%22%20font-family=%22Trebuchet%20MS,Arial,sans-serif%22%20text-anchor=%22middle%22%3EB%3C/text%3E%3C/svg%3E"><span>BassieWouters</span></div>
<div class="tv-manage-access-dialog__user-remove-column">
<div class="apply-common-tooltip tv-manage-access-dialog__user-remove-btn js-user-remove-btn" title="Remove access">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10" width="10" height="10">
<g fill="none" stroke="#758696" stroke-width="2">
<path d="M1.125 9.11L9.13 1.104M1.125 1.105L9.13 9.11"></path>
</g>
</svg>
</div>
</div>
</div>
</div>
</div>
<div class="sb-inner-shadow top i-invisible"></div>
<div class="sb-inner-shadow"></div>
<div class="sb-scrollbar-wrap">
<div class="sb-scrollbar sb-scrollbar-body ui-draggable ui-draggable-handle" style="height: 317.46px; top: 1px;"></div>
</div>
</div>
</div>
</div>
</div>
<div class="tv-dialog__close js-dialog__close">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13" width="13" height="13">
<path d="M5.182 6.596L1.293 2.707.586 2 2 .586l.707.707 3.889 3.889 3.889-3.889.707-.707L12.606 2l-.707.707L8.01 6.596l3.889 3.889.707.707-1.414 1.414-.707-.707L6.596 8.01l-3.889 3.889-.707.707-1.414-1.414.707-.707 3.889-3.889z"></path>
</svg>
</div>
</div>
EDIT
As requested I have attempted this change.
for user in result:
if user.text in unsubscribed:
self.driver.find_element_by_css_selector(f"[data-username='{user.text}'] svg").click()
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [data-username='snub-fighter'] svg
It's very strange, what you try to do there. Try something simple, like code below:
user_list = ['ladedimone', 'PaulAdelaar', 'Swaine123']
# you're on page with unsubscribe list using Selenium
for user in user_list:
driver.find_element_by_css_selector(f"[data-username='{user}'] svg").click()
It took a while but here is the solution.
def removeusers(self, unsubscribed, htmlsource):
#print("Missing users in Unsubscribed list:",unsubscribed)
wait(self.driver, 6).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Manage Access']"))).click()
time.sleep(3)
for name in unsubscribed:
#print( "//div[#data-username='{}']//div[contains(#class,'tv-manage-access-dialog__user-remove-btn')]".format(name))
try:
self.driver.find_element_by_xpath(
"//div[#data-username='{}']//div[contains(#class,'tv-manage-access-dialog__user-remove-btn')]".format(
name)).click()
print("REMOVED : ",name)
except Exception as e:
print(e)

Categories

Resources