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

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.

Related

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()

How to scrape a page and then perform a button click to go to next page for scraping using Selenium and BeautifulSoup

I am scraping a web page which has a table with child tr and td tags. I am able to scrape the first page properly. But to go to the next page I need a button click. I need some help in understanding that. I am using Selenium and Beautiful soup to get the page response.
The html for the button tag is as follows:
<input type="submit" name="RadGrid1$ctl00$ctl03$ctl01$ctl28" value=" " onclick="return false;" title="Next Page" class="rgPageNext">
The sample code that I have tried:
for i in range(0,14):
# code for scraping 1 page
some code here
btn = driver.find_element_by_xpath(xpath)
btn.click()
The button click goes to the next page but is not able to scrape info for any of the 2-14 pages. I have tried putting my scraping 1 page code in a for loop and added the button click logic at the end. It scrapes 1st page, performs a button click but doesn't go through to the next page. Instead it loops back to page 1.
As to what I can understand, I think you haven't updated the new url to the Beautifulsoup. After the click you take the current url of the new page and then perform scraping. Then only it will scrape the new page otherwise it contains the url of the old page and thus scrapes that page only.

Chrome extension - wait popup until script is done

I am trying to make a Chrome extension, everything is going well, except that before the content of the popup is filled with javascript(XMLHttpRequest - asynchronous) I see a small blank popup that has not yet been filled.
That is,
Before this loads
I see this
In the code, I am simply using document.getElementById to fill up the HTML. So it looks like
HTML:
<body>
<div id="status"></div>
</body>
JS:
document.getElementById('status').innerHTML = 'content of the request';
I see where this is coming from, since the popup is originally blank it shows that little blank box before javascript(XMLHttpRequest) is done. But How can I make it wait until the request is complete?
You can't manually display the browser/page action popup. This feature will not be implemented : source.
The most simple solution is to add a loading wheel gif to the html of the popup. It will display the popup until the content is changed by your code when the request is complete.
Another solution is to display a popup (not a browser/page action popup) when the user click on the browser/page action. This way you can wait for the request to display your popup.

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