How to click on dropdown list items through Selenium in VBA macro? - vba

I am trying to create a macro to download a file from a web page. I have coded the login and navigating to main download page however, unable to get codes to click on a drop-down menu on a web page. I need to click on 3 dots then click on Download xlsx to start downloading the file. I can not proceed to rest of the codes until file is downloaded. Here is the link to HTML properties of this dropdownlist
obj.FindElementsByClass("ant-dropdown-menu-item").Click

I had figured out the solution. I had to click on the blank space to get that drop down buttons appear. Then clicked as usually. I got the element path form Chropath chrome add on and used xpath.
Obj.FindElementByClass("insight__header").Click '-----------This clicks on blank space to show 3 dots.
Obj.FindElementByXPath("/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/header[1]/span[2]/div[1]/button[1]/i[1]/*").Click '---------This cicks on 3 dots and displays the menu.
Obj.FindElementByXPath("/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/ul[1]/li[4]/span[1]").Click '---------This clicks on Download xlxs button to start downloading the file.

Related

Selenium: How to get text without clicking on tab?

I'm trying to find text that is located on a specific tab. For some reason the text is available in the html but when I use the command driver.find_element_by_id('hand-graph-title-overview').text without clicking on the 'Overview' tab it returns a empty string. However, when I do click on the 'Overview' tab it will return 'Unpaired OOP' successfully. Does anyone know how to get the text without clicking on the tab?
Images of what I'm trying to scrape.
https://i.stack.imgur.com/9nSc0.png
https://i.stack.imgur.com/MyvDA.png
Maybe try and get the 'value' attribute of the element.
driver.find_element_by_id('hand-graph-title-overview').get_attribute('value')
The answer is no. You can't access the element from the other tab without focusing on it. Retrieval of text is totally based on the presence of the element on the current page. When you click on tab then automatically it gets loaded in the dom and then only you can access the element.

How to link a certain/specific page on a PDF document to a certain word/number on a Word doc?

How would I link a specific page on a PDF document to a certain word/number on a word doc?
Please follow these steps:-
On the menu bar, select Tools > Advanced Editing > Link Tool.Your mouse cursor will change from the hand cursor ( ) to . Use this tool to click and drag, drawing a box around the text that you want to link.
Once you have completed drawing the box, release the mouse button. The Create Link dialog box will display.
Select the Open a page in this document option.
In the Page field, type in the page number of the page you want the link to jump to when clicked.
Note: Make sure you type in the actual page number of the page to which you want to link. You can determine the correct page number by going to the page you want to link to, and then look at the bottom of the Adobe Acrobat screen ( ) to see what page you're on.
Click OK to apply the settings or click Cancel to exit without applying the settings.
After clicking OK in the above steps, the box that you drew around the text to link will display in
red. You can adjust the width and height of the box if you need to by clicking and dragging each
side of the box. If you want to change the appearance of the link, go to the "Adjusting the
Appearance of the Link" section of this document.
I hope that helps!

Selenium ClickandWait

Using id=incidentsCheckBox gets me an error but when clicking manually it shows up fine. What is the best way of capturing dynamically generated icons (incidentIcons), which pop up when a checkbox is clicked, which if click individually will show a popup data of status?

PDF creation with page refresh

I have a page with a viewPanel and a dialog. When an item in the viewPanel is clicked, the dialog opens, prompting the user to make changes to that item, and offering them the option to generate a report of the item in PDF format.
At first, I tried putting the PDF creation onto a button, as described here: http://www.eknori.de/2011-10-25/xpages-to-pdf-with-itext/ However, whenever the button is pressed, I get a "NotFoundError: DOM Exception 8" which seems to stem from the dojo JS. So currently I have an alternative whereby the button simply sets some sessionScope variables and opens a pdf.xsp XPage, where the variables are read back and the PDF is created.
The PDF gets created correctly, but it also means that the page that the user is on won't be refreshed to display their new change in the viewPanel. I've tried adding page redirects at the bottom of the XPage which creates the PDF, but with no luck.
So, how can I create a PDF and prompt a user to download it, but also refresh the page that they are currently on?
Are you isseuing an partial refresh on the button to hide your dialog and to execute the code for pdf generation? If so you I think that there is your problem. What you could do is to do a partial refresh on the onClose() method of the dialog to refresh the viewpanel. In the clientside onunload method you could open a so called xAgent which renders the pdf for you in a new window (window.open(pdf.xsp?docid=xxx). Take a look here: NotesIn9: 039 Creating PDF’s with XPages Part 2
Of cours the problem with this approach is that when you have a button / image in yoru viewpanel row that displays if the report has been created is not shown because the xagent runs after the / during the time the viewpanel row is being refreshed.

How to record a dropdown item which opens when clicked on the image?

In my application I have logout link as it is in gmail account. I have to click on a dropdown image to see the logout link, this is not recording when I am trying to record using sahi tool and I am not able to record the browse and upload event using sahi tool.
Thanks
You can record the items by hold the ctrl button and mouseover the particular item the sahi controller will show the element name in the Accessor text box . Copy that script and paste it in your script file and try to run