Forum

Vba click on the bu...
 
Notifications
Clear all

Vba click on the button to download files

5 Posts
3 Users
0 Reactions
359 Views
(@gracewithme)
Posts: 2
New Member
Topic starter
 

Hi All,
I'm happy to have such a form to clear Excel/vba based queries. This is the site that i got to know from my friend.

My query is, I'm new with Selenium automation. Although I'm able so far to open edge and access the required Web page.
but I'm unable to download the file.

I tried to click on the button using XPath but not able to do so for.

Code of the button where I need to click on "download" is placed below. Also i have listed vba code that i had tried.

<a href="#" class="btn btn-default" data-bind="click : downloadfiles, visible: $root.filesViewModel.files().length > 0">
<i class="fa fa-download js-app-action-li" aria-hidden="true"></i>
Download <strong data-bind="text:$root.filesViewModel.files().length">5</strong> Files
</a>

Sub DownloadFile()
Dim DR As WebDriver

Set DR = New EdgeDriver
Const URL = "url"
With DR
.Start "Edge"
.Get URL
.FindElementByXPath("//a[@class='btn btn-default'][1]").Click
Application.Wait Now + TimeSerial(0, 1, 0)
.Quit
End With
End Sub

When i tried with the above code i got the below error message, im not sure why i see this message.

Run-time error '13':
UnknownError
Element is obscured

Please let me know if you team need any thing that i have to do.

Thanks

 
Posted : 07/08/2020 8:04 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi,

I don't see how that code will work, URL isn't set to an actual URL?

Without the full VBA and HTML code from the web page it makes it difficult to give you an answer.

Can you please attach your workbook with code and either the URL to the web page, or the source code of the web page you are trying to get data from.

Thanks

Phil

 
Posted : 07/08/2020 8:40 am
(@gracewithme)
Posts: 2
New Member
Topic starter
 

Hi Philip,

Since those url details are related to my work environment, i'm not supposed to expose those details which you asked. Possible can you suggest me the error msg i got and how to overcome that "Error: Element is Obscured".

Thanks

Gold

 
Posted : 07/08/2020 9:21 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Gold,

Not being able to see the entire web page makes it difficult to give you code that will work, so I can only go with what you have provided.

If I copy/paste the HTML you've provided into a file D:/temp/gold.htm, the following code works for me using Chrome.  Should work for you too with Edge.

 

   Sub ClickButton()

      Dim driver As New Selenium.ChromeDriver

      With driver

         .Get "file:///D:/temp/gold.htm"

         Application.Wait (Now + TimeValue("00:00:05"))

         .FindElementByXPath("//a[@class='btn btn-default'][1]").Click

      End With

      Set driver = Nothing

   End Sub

 

Regards

Phil

 
Posted : 07/08/2020 9:55 pm
Anders Sehlstedt
(@sehlsan)
Posts: 970
Prominent Member
 

Hello,

I don't know if this issue is related, but fun things do happen in Edge if browser zoom is other than 100%.

Br,
Anders

 
Posted : 08/08/2020 2:31 am
Share: