Click on an element in Selenium (ElementClickInterceptedException) - html

I am using Selenium to find information in Kaggle.
In order to do so, I am looking to scrape information on people solutions.
When I navigate to this url: https://www.kaggle.com/allen-institute-for-ai/CORD-19-research-challenge/tasks?taskId=882.
There are people solutions at the end of the task.
I would like to click on those elements.
From the page source, it doesn't look like pressing the solution should navigate to notebook of the solution (the < a href="/{usename} opens the user info tab, and not the notebook tab).
This is how the html of an element looks like:
<li class="sc-qQkIG hIKhtZ">
<a href="/moghazy" target="_blank" rel="noopener" class="sc-pZMVu kiTgMN">
<div class="sc-oTPjJ cCLmQH"><img src="https://storage.googleapis.com/kaggle-avatars/thumbnails/777390-kg.jpg" alt="Moghazy" class="sc-pckkE ljVeKr"><img src="/static/images/avatier/avatier-expert#2x.png" alt="expert" class="sc-pjIPr cvnVIi"></div>
</a>
<div class="sc-qYgLf hNZirj">
<div class="sc-pRStN jTbOhh">
<div class="sc-AxheI sc-fznWqX sc-qanuI frNLaF">COVID-19 Literature Ranking + Web Scraping</div>
</div>
<div class="sc-psdQm hrPHBT"><span class="sc-fzpkJw sc-fznzOf sc-oToFz dtnpxb">Moghazy · <span title="Sat May 16 2020 02:44:32 GMT+0300 (Israel Daylight Time)">6 days ago</span> · Notebook · Python · 4 Comments</span></div>
</div>
<div class="sc-pJsLC cBTgaO">
<div class="sc-pZzGt eDxwsZ sc-pkjoF iehzxN">
<button class="MuiButtonBase-root MuiButton-root sc-oTcWe sc-paYYD hlGLPZ MuiButton-outlined" tabindex="0" type="button" state="no-vote" data-testid="vote-button-icon">
<span class="MuiButton-label label">
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="angle-up" class="svg-inline--fa fa-angle-up fa-w-10 " role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512">
<path fill="currentColor" d="M177 159.7l136 136c9.4 9.4 9.4 24.6 0 33.9l-22.6 22.6c-9.4 9.4-24.6 9.4-33.9 0L160 255.9l-96.4 96.4c-9.4 9.4-24.6 9.4-33.9 0L7 329.7c-9.4-9.4-9.4-24.6 0-33.9l136-136c9.4-9.5 24.6-9.5 34-.1z"></path>
</svg>
</span>
<span class="MuiTouchRipple-root"></span>
</button>
<button class="MuiButtonBase-root MuiButton-root sc-oTcWe sc-pjUyM kZNtvl MuiButton-outlined Mui-disabled Mui-disabled" tabindex="-1" type="button" disabled="" state="no-vote"><span class="MuiButton-label label">14</span></button>
</div>
</div>
</li>
I find the elements using this code:
elements = driver.find_element_by_class_name("sc-oUaSW").find_elements_by_xpath(".//li")
for element in elements:
element.click()
but I am getting the error:
Message:
element click intercepted: Element ... is not clickable
but when I click on it in the server, it is clickable.
What am I doing wrong?

There are several issues to address:
Element is not clickable because it is not in focus. You need to move to it first.
The click opens a new tab. This requires its own handling.
Moving back to the original tab to click the next item.
This snippet should work:
main_window = driver.current_window_handle #this relates to issues 2, 3
elements = driver.find_element_by_class_name("sc-oUaSW").find_elements_by_xpath(".//li")
for element in elements:
ActionChains(driver).move_to_element(element).click().perform() #this addresses issue 1
#element.click()
driver.switch_to.window(driver.window_handles[1]) #this relates to issue 2
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//a[#class='KernelViewerContext_KernelTitle-sc-rdaqnd chqxNN']")))
#time.sleep(3)
#do whatever you wish with the tab/task here
driver.close()
driver.switch_to.window(main_window) # close tab and switch back to original browser tab (issue 3)
These imports are required for the above to work:
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains

Related

How to convert a html page to a complete Vue or React project?

I am currently working on a dashboard based on AdminLTE 3. I removed the parts that I don't need and made some changes on the AdminLTE HTML and CSS files. The thing is I need this project to be a Vue or a React project. For now I only need the index.html (an empty dashboard, navbar, sidebar and a footer). There is one main CSS file which has all the classes that the project uses and there are some js files.
I tried to create an empty Vue project and create components like Navbar.vue, Footer.vue, Sidebar.vue etc. But I don't know how to integrate this one big CSS file for all of these and Js files as well. What should I do? I know there is no way to put all the script tags and links inside every components, that didn't work. Also I couldn't manage to use these files on the App.vue
Is there any way that I can convert this HTML project into a Vue or a React one?
Vue is incrementally adoptable. And very small.
Which means you can use it to render just one button. Or you can render the entire contents of your page with it. Your choice.
Also, you can just take the existing HTML and place it inside the template of a .vue single file component (SFC). It doesn't even need a <script> tag.
Example:
Vue.component('your-question', {
template: `
<div class="post-layout">
<div class="votecell post-layout--left">
<div class="js-voting-container grid fd-column ai-stretch gs4 fc-black-200" data-post-id="64535387">
<button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer fc-theme-primary" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" aria-describedby="--stacks-s-tooltip-9i3a4gec"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button><div id="--stacks-s-tooltip-9i3a4gec" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This question shows research effort; it is useful and clear<div class="s-popover--arrow"></div></div>
<div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center c-pointer" itemprop="upvoteCount" data-value="1" role="button" tabindex="0" data-s-tooltip-placement="right" data-controller="null s-tooltip" aria-describedby="--stacks-s-tooltip-lk3p5mtq">0</div><div id="--stacks-s-tooltip-lk3p5mtq" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">View upvote and downvote totals.<div class="s-popover--arrow"></div></div>
<button class="js-vote-down-btn grid--cell s-btn s-btn__unset c-pointer" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="true" aria-label="Down vote" data-selected-classes="fc-theme-primary" aria-describedby="--stacks-s-tooltip-ib7zwamw"><svg aria-hidden="true" class="m0 svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 10h32L18 26 2 10z"></path></svg></button><div id="--stacks-s-tooltip-ib7zwamw" class="s-popover s-popover__tooltip pe-none wmx2" aria-hidden="true" role="tooltip" style="margin: 0px;">This question does not show any research effort; it is unclear or not useful (click again to undo)<div class="s-popover--arrow" style=""></div></div>
<button class="js-bookmark-btn s-btn s-btn__unset c-pointer py4 js-gps-track" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Bookmark" data-selected-classes="fc-yellow-600" data-gps-track="post.click({ item: 1, priv: 17, post_type: 1 })" aria-describedby="--stacks-s-tooltip-jn0zc88f">
<svg aria-hidden="true" class="svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M6 1a2 2 0 00-2 2v14l5-4 5 4V3a2 2 0 00-2-2H6zm3.9 3.83h2.9l-2.35 1.7.9 2.77L9 7.59l-2.35 1.7.9-2.76-2.35-1.7h2.9L9 2.06l.9 2.77z"></path></svg>
<div class="js-bookmark-count mt4 d-none" data-value=""></div>
</button><div id="--stacks-s-tooltip-jn0zc88f" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Bookmark this question.<div class="s-popover--arrow"></div></div>
<a class="js-post-issue grid--cell s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/64535387/timeline" data-shortcut="T" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-ud2iy1dm"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 113.73 6.77L8.2 14.3A6 6 0 105 9l3.01-.01-4 4-4-4h3L3 9zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5z"></path></svg></a><div id="--stacks-s-tooltip-ud2iy1dm" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>
</div>
</div>
<div class="postcell post-layout--right">
<div class="s-prose js-post-body" itemprop="text">
<p>I am currently working on a dashboard based on AdminLTE 3. I removed the parts that I don't need and made some changes on the AdminLTE HTML and CSS files. The thing is I need this project to be a Vue or a React project. For now I only need the index.html (an empty dashboard, navbar, sidebar and a footer). There is one main CSS file which has all the classes that the project uses and there are some js files.</p>
<p>I tried to create an empty Vue project and create components like Navbar.vue, Footer.vue, Sidebar.vue etc. But I don't know how to integrate this one big CSS file for all of these and Js files as well. What should I do? I know there is no way to put all the script tags and links inside every components, that didn't work. Also I couldn't manage to use these files on the App.vue</p>
<p>Is there any way that I can convert this HTML project into a Vue or a React one?</p>
</div>
<div class="mt24 mb12">
<div class="post-taglist grid gs4 gsy fd-column">
<div class="grid ps-relative">
<span class="edit-tags-wrapper">htmlreactjsvue.jsdashboardadminlte<span>Edit tags</span></span>
</div>
</div>
</div>
<div class="mb0 ">
<div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4">
<div class="grid--cell mr16" style="flex: 1 1 100px;">
<div class="post-menu">
share<div class="s-popover z-dropdown" style="width: unset; max-width: 28em;" id="se-share-sheet-0"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this question</span> <span class="js-subtitle">(includes your user id)</span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between mbn4"><button class="js-copy-link-btn s-btn s-btn__link">Copy link</button>CC BY-SA 4.0<div class="js-social-container"></div></div></div>
<span class="lsep">|</span>
edit
<span class="lsep">|</span>
<button id="btnFollowPost-64535387" class="s-btn s-btn__link fc-black-400 h:fc-black-700 pb2 js-follow-post js-follow-question js-gps-track" role="button" data-gps-track="post.click({ item: 14, priv: 17, post_type: 1 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-rlrg4nxp">
follow
</button><div id="--stacks-s-tooltip-rlrg4nxp" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this question to receive notifications<div class="s-popover--arrow"></div></div>
<span class="lsep">|</span>
close
<span class="lsep">|</span>
flag
<span class="lsep">|</span>
<div data-controller="s-popover" data-s-popover-reference-selector="#btnProtectLoggedIn">
<button id="btnProtectLoggedIn" class="s-btn s-btn__link fc-black-400 h:fc-black-700 px4 pb2 js-gps-track" role="button" aria-controls="divConfirmProtect" data-gps-track="post.click({ item: 12, priv: 17, post_type: 1 })" data-action="s-popover#toggle" data-s-popover-placement="bottom-start" data-s-popover-toggle-class="is-selected" title="disallow answers by anonymous and very new low rep users">
protect
</button>
<div class="s-popover px16" id="divConfirmProtect" role="menu" aria-hidden="true">
<p class="bold mb4">Are you sure?</p>
<p class="mb12">Protect this question if it is highly active and likely to receive spam activity or non-answers (e.g. "Me too!" "Thanks!"). Anonymous and low reputation users can’t answer protected questions. Learn more.</p>
<p class="mb0">
<button id="protect-post-64535387" class="s-btn s-btn__primary mr8" type="button" aria-pressed="false">Protect question</button>
<button class="s-btn s-btn__link" type="button" aria-pressed="false" aria-label="Close" data-action="s-popover#toggle">Cancel</button>
</p>
<div class="s-popover--arrow"></div>
</div>
</div>
</div>
</div>
<div class="post-signature owner grid--cell">
<div class="user-info ">
<div class="user-action-time">
asked <span title="2020-10-26 10:31:30Z" class="relativetime">yesterday</span>
</div>
<div class="user-gravatar32">
<div class="gravatar-wrapper-32"><img src="https://lh3.googleusercontent.com/a-/AOh14Ghue30DHLGWKxu5iK2LpyQskJVNNGvkiWGN2Wt6=k-s32" alt="" width="32" height="32" class="bar-sm"></div>
</div>
<div class="user-details" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
Yasin Demirkaya<span class="d-none" itemprop="name">Yasin Demirkaya</span>
<div class="-flair">
<span class="reputation-score" title="reputation score " dir="ltr">9</span><span title="2 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">2</span></span><span class="v-visible-sr">2 bronze badges</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="post-layout--right">
<div id="comments-64535387" class="comments js-comments-container bt bc-black-075 mt12" data-post-id="64535387" data-min-length="15">
<ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="true" data-cansee="false" data-comments-unavailable="false" data-addlink-disabled="false">
</ul>
<div class="comment-form">
<form id="add-comment-64535387" class="" data-placeholdertext="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments."><div class="js-comment-form-layout d-flex fw-wrap jc-end mt8"><div class="w75 fl-grow1"><div class="js-comment-text-input-container"><textarea name="comment" class="s-textarea js-comment-text-input" rows="3" cols="68" placeholder="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments."></textarea></div><span class="text-counter cool">enter at least 15 characters</span> <span class="form-error"></span></div><div class="d-flex fd-column jc-space-between pb4 mb16 ml8"><button type="submit" class="s-btn s-btn__primary">Add Comment</button><button type="button" class="js-edit-comment-cancel s-btn s-btn__link ta-left px2 mt4"></button><br><button type="button" class="js-comment-help-link s-btn s-btn__link ta-left px2">help</button></div></div></form>
</div>
</div>
<div id="comments-link-64535387" style="display: none;">
<a class="js-add-link comments-link" title="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments." href="#" role="button">add a comment</a>
<span class="js-link-separator dno"> | </span>
<a class="js-show-link comments-link dno" title="expand to show all comments on this post" href="#" onclick="" role="button"></a>
</div>
</div>
</div>
`
});
new Vue({
el: '#app'
})
#app {
width: 600px;
}
html, body {
min-width: 0 !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Shared/stacks.css?v=3b16a418cc4c">
<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=fdd4b4684691">
<div id="app">
<your-question />
</div>
Is it Vue? Entirely.
Does it have any reactive data? Not yet.
How much did it take? A copy-paste, basically.
Obviously, it's more than just that. You'll also need to load the javascript and it can't be in the <template>. And you'll likely want to cut portions of your markup into separate components. But, for starters, all you need to do is present the markup and load your scripts. Everything should work as if it wasn't Vue rendering it.
To make it clearer: Vue can render anything and it doesn't care what it is. It can be an Angular app or a React app or even another Vue app.
A tool like the one you're looking for does not and cannot exist, because it wouldn't know what part of the existing markup should be transformed into a Vue component.
But, basically, each Vue app is one big component, which replaces the DOM element you mount it on.
In the above example this is all the app's markup:
<div id="app">
<your-question />
</div>
And <your-question>, defined as a Vue component does the rendering, when you create a
new Vue({ el: '#app '}).
Also note that, once you create a big Vue component, most IDEs will allow you to select a portion of its template and generate a new Vue component from the selected markup, creating the new SFC for you, copying the template portion into the new file and replacing the removed markup with the new component's tag, also resolving necessary imports and any required methods/computed/data or props.
Since the css file already included all the styles you need, just referencing it in the index.html if you created the project via vue-cli.
For instance, I have a css file named app.css.
Copied it to public folder, where the index.html locates here as well.
public/
- index.html
- app.css
Open index.html, reference as that in HTML. But use <% BASE_URL %> at the beginning.
<link rel="stylesheet" href="<%= BASE_URL %>app.css">
In your case, you don't have to write any css code in vue components. Maybe just copying and pasting the HTML code is working. If you hope to override the style within a specific component, use <style scoped> to avoid impacting global styles.

Finding one element by XPATH using another element

I have a website from which I want to extract values using XPATH. These values are changable but generally they are in same repeated node trees (there are hundreds of same structurally node trees with this one changeable value). This is example of one of these tree:
<div style="position: absolute; left: 0px; top: 178px; height: 89px; width: 100%;">
<a class="css-18rtd1e" href="/offers/appunite-backend-developer-elixir">
<div class="css-ysfq6d"></div>
<div class="css-1anw03b"><img src="https://bucket.justjoin.it/offers/company_logos/thumb/22f3ad736e1bc02190ff8beb9d4c55a4de297104.png?1572275788" alt="AppUnite" class="css-h8h6qh"></div>
<div class="css-rmb95w">
<div class="css-fxb39h">
<div class="css-18hez3m">
<div class="css-1x9zltl">Elixir Developer</div>
<div class="css-1suuexb"><span class="css-5fhp0m">Online<br>interview</span></div>
</div>
<div class="css-16tql6o">
<span class="css-112rr0w">7 000 - 11 000 PLN </span>
<div class="css-hw5uoy">New</div>
</div>
</div>
<div class="css-m6o8yl">
<div class="css-pdwro7">
<div class="css-ajz12e">
<svg class="MuiSvgIcon-root" focusable="false" viewBox="0 0 24 24" aria-hidden="true">
<path d="M12 7V3H2v18h20V7H12zM6 19H4v-2h2v2zm0-4H4v-2h2v2zm0-4H4V9h2v2zm0-4H4V5h2v2zm4 12H8v-2h2v2zm0-4H8v-2h2v2zm0-4H8V9h2v2zm0-4H8V5h2v2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8v10zm-2-8h-2v2h2v-2zm0 4h-2v2h2v-2z"></path>
</svg>
AppUnite
</div>
<div class="css-1ihx907">
<svg class="MuiSvgIcon-root" focusable="false" viewBox="0 0 24 24" aria-hidden="true">
<path d="M12 2C8.13 2 5 5.13 5 9c0 4.17 4.42 9.92 6.24 12.11.4.48 1.13.48 1.53 0C14.58 18.92 19 13.17 19 9c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path>
</svg>
Poznań
</div>
<span class="css-5fhp0m">Online interview</span>
</div>
<div class="css-1ij7669">
<div class="tag css-1g8us6r">Phoenix</div>
<div class="tag css-1g8us6r">Elixir</div>
<div class="tag css-1g8us6r">Web Applications</div>
</div>
</div>
</div>
</a>
</div>
I want to extract word AppUnite and it would be simple task but there is one condition to be met: I need to use in my XPATH element containing text from "css-1x9zltl" class (in this case it would be word Elixir Developer). In other words I want to get access to AppUnite using extracted word from "css-1x9zltl" class. So beginning is simple: //div[contains(#class, "css-1x9zltl") and text()="Elixir Developer"] but what next?
You want to get the names of the hiring companies.
Since the names of the #class attributes are fixed (css-1x9zltl,css-ajz12e) on JJI website, you can use :
//div[contains(#class,"css-1x9zltl")][contains(.,"Elixir Developer")]/following::div[#class="css-ajz12e"][1]/text()
Note this will select "Elixir Developer", "Senior Elixir Developer" offers. To be more strict, remove the second contains :
//div[contains(#class,"css-1x9zltl")][.="Elixir Developer"]/following::div[#class="css-ajz12e"][1]/text()
If I understand you correctly, in the case of the sample in your question, an xpath expression like this may do the trick:
//div[contains(#class, "css-1x9zltl")]["Elixir Developer"]/ancestor::div[#class="css-fxb39h"][1]/following-sibling::div [#class="css-m6o8yl"]//div[#class="css-ajz12e"]/text()
This expression basically locates the <div> node meeting your class and text conditions, goes up to the first ancestor which is a sibling of the <div> node in which the target text is buried, then goes down to the <div>child node (of that sibling) which contains the target text, and finally selects the text node of that child node.

VBA-Wedriver-Selenium-Xpath - Modify Class Value - Click Button -Excel

I am opening a website using Chrome Webdriver.
I wanted to Modify value to 12 instead of 10 in a box
HTML Code
<div class="input-currency input-colors">
<input type="tel" autocomplete="off" class="input-currency__input" data-test="deal-amount-input" maxlength="9" value="10" />
<div class="input-currency__values"><span class="input-currency__value">10</span> <span class="input-currency__sign psign">Đ</span></div>
</div>
My Codes
Dim Bot As WebDriver
Dim posts As WebElements, post As WebElement
Set Bot = New WebDriver
Bot.Start "chrome"
Bot.Get "https://olymptrade.com/platform#"
Bot.FindElementsByXPath("//span[contains(#class,'input-currency__value')]").Values = 12
Bot.FindElementByClass("input-currency input-colors").Text
Also there is a button of Buy with Green color, I wanted to click on it.
HTML Code
<div class="deal-buttons__item deal-buttons__item_up">
<button data-test="deal-button-up" class="deal-buttons__button deal-buttons__button_up">
<span>
<span class="deal-buttons__text">80%</span>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="#FFF" fill-opacity="0.5" class="deal-buttons__svg deal-buttons__svg_arrow">
<path d="M14.6 8l-8.3 8.3a1 1 0 0 0 1.4 1.4L16 9.4V17a1 1 0 0 0 2 0V7a1 1 0 0 0-1-1H7a1 1 0 1 0 0 2h7.6z"></path>
</svg>
</span>
</button>
</div>
My Code
Bot.FindElementsByXPath("//span[contains(#class,'deal-buttons__text ')]").Click
Bot.FindElementsByXPath("//button[contains(#class,'deal-buttons__button deal- buttons__button_up')]").Click
I wanted to change the value and Click on buy button using selenium webdriver
provide me hint on my mistake
FindElements returns a collection. You want a single webElement i.e. a single item of that collection. You need to determine the appropriate index and use that or, if want first match, use methods, for example as shown below, which are singular.
Bot.FindElementByCss(".input-currency input").SendKeys "12" 'though you may need to clear element first
If need to clear first then:
With Bot.FindElementByCss(".input-currency input")
.Clear
.SendKeys "12"
End With
The button html is not provided by you but again you need singular method or index. Assuming want first, and xpath correct:
Bot.FindElementByXPath("//span[contains(#class,'deal-buttons__text ')]").Click

BootstrapVue two tooltips appearing on the same element while having different targets?

I'm working in Vue with BootstrapVue and the bottom 2 tooltips I'm using are both appearing on the button which the click to mask this value button is targeted to. The tooltip which will contain the SSN is also appearing only on top of the button when it should be only where the span is.
I'm not sure why this is happening given that the IDs are seperated and I'd assume that it'd just place the SSN tooltip onto the span so it'd render there.
Markup:
<span class="app-titlebar__client-data-item non-draggable">
<div v-if="!hideSsn"
class="ssn-text"
#mouseenter="checkDataItem($event, 'ssn')"
#mouseleave="hideTooltips">
<button class="adv-btn adv-btn--naked app-titlebar__unmasked-btn"
id="titlebar-ssn-eye-hide"
#click="maskSsn(true)"
#mouseenter="hoverSsnMask(true)"
#mouseleave="hoverSsnMask(false)">
<svg class="us-icon-svg us-icon-svg--inline us-icon-svg--xs disable-pointer"
role="img"
focusable="false">
<use xlink:href="#adv-icons-svg_unmasked"></use>
</svg>
</button>
<span id="titlebar-ssn">
{{ssn}}
</span>
</div>
<div v-else
class="ssn-text">
<button class="adv-btn adv-btn--naked app-titlebar__mask-btn"
id="titlebar-ssn-eye-show"
#mouseenter="hoverSsnMask(true)"
#mouseleave="hoverSsnMask(false)"
#click="maskSsn(false)">
<svg class="us-icon-svg us-icon-svg--inline us-icon-svg--xs disable-pointer"
role="img"
focusable="false">
<use xlink:href="#adv-icons-svg_masked"></use>
</svg>
</button>
{{ssnMasked}}
</div>
</span>
Tooltips:
<b-tooltip v-if="clientInContext && ssn && hideSsn"
target="titlebar-ssn-eye-show"
:disabled.sync="disableSsnTooltip"
:show.sync="showSsnTooltip"
triggers="hover"
placement="bottom">
Click to temporarily display this value
</b-tooltip>
<b-tooltip v-if="clientInContext && ssn && !hideSsn"
target="titlebar-ssn-eye-hide"
:disabled.sync="disableSsnTooltip"
:show.sync="showSsnTooltip"
triggers="hover"
placement="bottom">
Click to mask this value
</b-tooltip>
<b-tooltip v-if="clientInContext && ssn && !hideSsn"
target="titlebar-ssn"
:disabled.sync="disableSsnTooltip"
:show.sync="showSsnTooltip"
triggers="hover"
placement="bottom">
{{ssn}}
</b-tooltip>
Since you are using v-if/v-else, make sure you place a unique keyeither on the button wrapper div or the button. What is most likely happening is that Vue is re-using the same element reference and just updating bits of it. b-tooltip caches the element reference when it is mounted.

Trying to click on the <Button> tag , in selenium web driver using python

I have been trying to click on a button for the following html by using python (selenium webdriver)
<div class="cssm-TopNav_printIcon_2VzB_">
<button type="button" aria-label="Print" title="Print" class="cssm-Button_button_2a549 cssm-Button_secondary_22F7i cssm-Button_sm_EPQ2U">
<div class="" aria-hidden="true" color="black" style="display: inline-block; height: 16px; width: 16px; min-height: 16px; min-width: 16px; max-height: 16px; max-width: 16px;">
<svg viewBox="0 0 24 24" class="" focusable="false">
<g fill="#3C3F51">
<path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z">
</path>
<path d="M0 0h24v24H0z" fill="none">
</path></g></svg></div></button>
<button type="button" class="cssm-Button_button_2a549 cssm-Button_primary_1gH9y cssm-Button_sm_EPQ2U">
<!-- react-text: 314 -->View Custody List<!-- /react-text -->
</button>
I am trying to click on the second button in the above html.
I am using find_element_by_tag because i think for html <button> tag it should work .I am using following code snippet to click on it , but getting-:element not visible
driver.find_element_by_tag_name("button").click()
Any help will be appreciated!!
Selenium with Python documentation UnOfficial
Hii there
Selenium provides the following methods to locate elements in a page:
find_element_by_id
find_element_by_name
find_element_by_xpath
find_element_by_link_text
find_element_by_partial_link_text
find_element_by_tag_name
find_element_by_class_name
find_element_by_css_selector
To find multiple elements (these methods will return a list):
find_elements_by_name
find_elements_by_xpath
find_elements_by_link_text
find_elements_by_partial_link_text
find_elements_by_tag_name
find_elements_by_class_name
find_elements_by_css_selector
this is how your code should be
#this code will get the list of tags and select the second tag from the list
element = driver.find_elements_by_tag_name('button')[1]
#this will click the element
element.click()
There is probably more than one button tag on the page, try to be more explicit, like:
driver.find_element_by_class_name("cssm-Button_primary_1gH9y").click()
or even better, give the button an ID and use
driver.find_element_by_id("the-button-id").click()