How to Click on Role=Button with Selenium - azure

I have the need to make selenium press a specific button but I have no knowledge of how to do it, it is a Role=Button, It is on the Microsoft Azure website in the command console that it has implemented called Cloud Shell, here is an image.
Well I already have everything I need created but I am having problems only in this part, I would like to click where it says PowerShell.
| Button PowerShell
XPATCH
//*[#id="os-ps-option"]
HTML
<div os-type="Linux" shell-type="pwsh" id="os-ps-option" class="os-option" role="button" tabindex="4" title="PowerShell" aria-label="PowerShell" aria-level="6">PowerShell</div>
| Button Bash
XPATCH
//*[#id="os-bash-option"]
HTML
<div os-type="Linux" shell-type="bash" id="os-bash-option" class="os-option" role="button" tabindex="3" title="Bash" aria-label="Bash" aria-level="6">Bash</div>

Related

How to prevent v-main to shift when v-navigation-drawer is opened ? (Vuetify, Vue.js 2, Nuxt, Typescript)

I'm building an app with a v-app component at the root, using a v-navigation-drawer and I'd like to add a "Chat" page, where I'd also like to use v-navigation-drawer.
Problem is components don't display correctly. When I open the v-navigation-drawer of the app, it shifts the v-main of the chat page.
Opened app navigation
Closed app navigation, what I'd like regardless of whether the menu is collapsed or not
Here is my chat page's template:
<template>
<v-layout>
<v-navigation-drawer
permanent
color="deep-purple accent-6"
v-model="drawer"
:mini-variant.sync="mini"
>
<v-list-item class="px-2">
<v-list-item-avatar>
<v-img
src="https://media-exp1.licdn.com/dms/image/C4D03AQHYJ44y1nW7Rw/profile-displayphoto-shrink_800_800/0/1634940206364?e=1645660800&v=beta&t=ni_NG94SNNVHDbzpVEtKwftayQzDy1bDtse2FavjDSU"
></v-img>
</v-list-item-avatar>
<v-list-item-title>Cosmic Darine</v-list-item-title>
<v-btn icon #click.stop="mini = !mini">
<v-icon>mdi-chevron-left</v-icon>
</v-btn>
</v-list-item>
<v-divider></v-divider>
<v-list dense>
<v-list-item v-for="item in menuItems" :key="item.title" link>
<v-list-item-icon>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-main>
<v-container>
<v-row>
I am a content
</v-row>
<v-row>
<write-bar />
</v-row>
</v-container>
</v-main>
</v-layout>
</template>
Does anyone have a solution for this problem?
I managed to find a solution. I added 'absolute' as a prop to v-navigation-drawer. The menu open above the content (I wanted that, so it's okay) and doesn't shift the content anymore. But if anyone would like to shift content when it opens only when needed, I guess you have to use the #media rule and margin with a negative value to shift back when the screen width is under a specific value.

Not able to click on specific print button in IE using VBA

I am trying to click on a print button on a specific web page, but cannot figure out the correct VBA code.
This is the print portion of my code:
With IE
.Document.querySelector("[data-testid='moreActionsButton']").Click
.Document.querySelector("[data-testid='createPdfButton']").Click
.Document.querySelector("[data-testid='detailed-button']").Click
.Document.querySelector("[data-testid='download-pdf-button']").Click
End With
This is the code on the web page for the button I am trying to click:
<div class="PdfForm__ButtonBar-sc-1h3mt9w-0 bjYOJP">
<button class="Button-sc-19jm674-2 kWKZnE"
data-testid="createPdfButton" variant="success"
type="submit">Download PDF</button>
</div>
Please note the the print options are in a pop-up so submit does not work. I also tried doing another query selector by as you can see the testid is the same as another step. Everything works up to this point.

Button element not interactable

I've been building an automated checkout script in Python 3.8 for the following website https://fasttimes.com.au/ (site built using Magento) and all buttons, drop downs, inputs etc have functioned up until this point. At the shipping selection stage however the button responsible for saving shipping details and allowing proceeding to billing stage, according to the python console reads; "Message: element not interactable".
I have tried using execute_script to directly interact with the site, this does not yield an error and says it's completed, but within the WebDriver the button hasn't actually been clicked and so proceedings to the next step of checkout do not take place. As for 'Action Chains'. they simply yield the error above, same as finding by XPATH or CSS_Selector. I've tried using the import 'Keys' and attempting to action the button with the ENTER key, as well as using the WebDriver substitute .send_keys(u'\ue007') to no avail. Before it's mentioned below I've also tried using waits, however maybe I'm doing them wrong?
E.g
element = WebDriverWait(driver, 15).until(
ec.presence_of_element_located((By.ID, "login:guest")))
Correct me if above line is incorrect formatting
Site's HTML is as follows:
<div class="buttons-set" id="shipping-method-buttons-container">
<p class="back-link"><small>« </small>Back</p>
<button type="button" class="button" onclick="shippingMethod.save()"><span><span>Continue</span></span></button>
<span id="shipping-method-please-wait" class="please-wait" style="display:none;">
<img src="https://static.fasttimes.com.au/skin/frontend/ultimo/default/images/opc-ajax-loader.gif" alt="Loading next step..." title="Loading next step..." class="v-middle"> Loading next step... </span>
</div>
My current code is:
driver.find_element_by_xpath("//*[#id='shipping-method-buttons-container']/button").send_keys(u'\ue007')
Any suggestions would be greatly appreciated. I believe the button that I'm trying to interact with is
<button type="button" class="button" onclick="shippingMethod.save()"><span><span>Continue</span></span></button>
...but I'm not too sure. I feel like I've at this point exhausted all possible avenues, but I refuse to believe this damned button isn't intractable! Thank you:)
As you've mentioned you want to proceed to Billing stage, I understand you are at step 1 of the checkout process. Am saying this because what you have identified with xpath //*[#id='shipping-method-buttons-container']/button is the button at step 4 Shipping Method, which is indeed not intractable yet.
You need to select the Checkout Method first, and carry on from there. Give this a try:
driver.find_element_by_id('login:guest').click() # select the "Checkout as Guest" radio button
WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH,"//*[#id='onepage-guest-register-button']")))
driver.find_element_by_xpath("//*[#id='onepage-guest-register-button']").click() # click Continue
Alternatively, if it's step 4 you're really stuck at:
WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH,"//*[#id='shipping-method-buttons-container']/button")))
driver.find_element_by_xpath("//*[#id='shipping-method-buttons-container']/button").click()

Cucumber/Capybara Selecting Button from Specific Class?

So i've ran into an issue, im trying to click a button...which unfortunately has the same text (IE there are 2 buttons on the page which the same text, basically a save button)
Lets pretend the button text is just "Save".
I did notice that they had different classes.
<button data-action="submit" class="btn btn-primary btn-save">Save</button>
whereas the other button is:
<button name="button" type="submit" class="btn btn-primary set-right">
<i class="glyphicon glyphicon-floppy-disk"></i> Save
</button>
I know glypicon is just an icon set....but they both seem to belong to the same class? but have different class names? (Sorry im not familiar with Rails)
It doesn't honestly matter which one I select as they both have the same function. I've seen where you can use xpath? but aren't we supposed to use css selectors or something now? (As in thats the newest way?) I may be wrong....
Could I use something like:
find(:xpath, '//button[#class="btn-save"]').click
Im trying to avoid "rails" only solutions, as not all the websites I test on are rails based.
You have various possibilities:
1) Find the button by its class
find(button.btn.btn-primary.btn-save).click
2) Find the button by its css selector or xpath (you can copy them using Google Chrome: right click -> Inspect -> right click on your element -> copy css or xpath)
find(:css, "your button css selector").click
find(:xpath, "your button xpath").click
If both buttons really do the same thing then you could always just do
first(:button, 'Save', minimum: 1).click
which will be less prone to breakage as your page structure changes than using an xpath selector. The minimum:1 option will just make #first wait a bit until at least one button is on the page (like find would) - it may not be necessary depending on your test structure

Watir :- click an image button?

I have am using firefox and i have modified its user agent to make it behave like iphone web browser. now when i open google.com using watir and now i want to click on the searh button which is an image in mobile view. how to do that.
To click an image
<img id="logo">
try this
browser.image(:id => "logo").click
If the image is actually a button
<input type="image" id="logo">
try this
browser.button(:id => "logo").click
The next time please provide relevant HTML.
Also, take a look at HTML Elements Supported by Watir page.

Resources