Automating Firefox using Selenium and VBA

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Automating Firefox using Selenium and VBA

thomas alexander lawford granger
Hi,

I've well versed in VBA programming and I've now tried moving into Firefox automation with little success. I've been trying for several months now to automate Firefox through selenium.

I am using: 
- MS Office Professional Plus 2010 
- Firefox 34.0.5 (I read Selenium doesn't work with higher versions of FF)
- Selenium IDE 2.4.0
- Selenium Wrapper 1.0.17.0
- Selenium Basic 2.0.9.0

I have recorded the following code in selenium IDE, outputted it to VBA script; however whenever I try running the code in VBA It trips up and stalls. 
___________________________________________________________________________
  Dim driver As New SeleniumWrapper.WebDriver
  Dim By As New By, Assert As New Assert, Verify As New Verify, Waiter As New Waiter
  driver.Start "firefox", "https://www.ebay.co.uk/"
  driver.setImplicitWait 5000

  driver.Get "/"
  driver.FindElementByLinkText("Sign in").Click
  driver.FindElementById("2031759456").Clear
  driver.FindElementById("2031759456").SendKeys USERNAME
  driver.FindElementById("707377953").Clear
  driver.FindElementById("707377953").SendKeys PASSWORD
  driver.FindElementById("sgnBt").Click
  driver.FindElementById("941057401").Clear
  driver.FindElementById("941057401").SendKeys PASSWORD
  driver.FindElementById("sgnBt").Click
  
  driver.stop
___________________________________________________________________________

I can't break out of the code and after a timeout period I get a message "Microsoft Excel is waiting for another application to complete an OLE action". I have to forcefully close Excel in task manager.

I've been trying a load of different things with no success. Can someone please help me?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f494dea5-b1ed-41b2-8891-f81d156a054a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Automating Firefox using Selenium and VBA

David
If you're versed in VBA (which is also VB, VBscript), why not try this alternative if the Selenium VBA binding is giving you issues: http://htejera.users.sourceforge.net/vbswebdriver/

On Tuesday, May 22, 2018 at 2:55:43 PM UTC-7, thomas alexander lawford granger wrote:
Hi,

I've well versed in VBA programming and I've now tried moving into Firefox automation with little success. I've been trying for several months now to automate Firefox through selenium.

I am using: 
- MS Office Professional Plus 2010 
- Firefox 34.0.5 (I read Selenium doesn't work with higher versions of FF)
- Selenium IDE 2.4.0
- Selenium Wrapper 1.0.17.0
- Selenium Basic 2.0.9.0

I have recorded the following code in selenium IDE, outputted it to VBA script; however whenever I try running the code in VBA It trips up and stalls. 
___________________________________________________________________________
  Dim driver As New SeleniumWrapper.WebDriver
  Dim By As New By, Assert As New Assert, Verify As New Verify, Waiter As New Waiter
  driver.Start "firefox", "<a href="https://www.ebay.co.uk/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.ebay.co.uk%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH0oJX8Tr1FckMrLQkVwZeQgKzz_A&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.ebay.co.uk%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH0oJX8Tr1FckMrLQkVwZeQgKzz_A&#39;;return true;">https://www.ebay.co.uk/"
  driver.setImplicitWait 5000

  driver.Get "/"
  driver.FindElementByLinkText("Sign in").Click
  driver.FindElementById("2031759456").Clear
  driver.FindElementById("2031759456").SendKeys USERNAME
  driver.FindElementById("707377953").Clear
  driver.FindElementById("707377953").SendKeys PASSWORD
  driver.FindElementById("sgnBt").Click
  driver.FindElementById("941057401").Clear
  driver.FindElementById("941057401").SendKeys PASSWORD
  driver.FindElementById("sgnBt").Click
  
  driver.stop
___________________________________________________________________________

I can't break out of the code and after a timeout period I get a message "Microsoft Excel is waiting for another application to complete an OLE action". I have to forcefully close Excel in task manager.

I've been trying a load of different things with no success. Can someone please help me?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/cc4add2f-610f-4ea3-9d36-15efd8e657aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Automating Firefox using Selenium and VBA

Nilton da Silva
Enter the developer tab, look for the tools tab and click References and see if this is enabled the selenium wrapper. I think that might be it.

2018-05-25 1:01 GMT-03:00 David <[hidden email]>:
If you're versed in VBA (which is also VB, VBscript), why not try this alternative if the Selenium VBA binding is giving you issues: http://htejera.users.sourceforge.net/vbswebdriver/

On Tuesday, May 22, 2018 at 2:55:43 PM UTC-7, thomas alexander lawford granger wrote:
Hi,

I've well versed in VBA programming and I've now tried moving into Firefox automation with little success. I've been trying for several months now to automate Firefox through selenium.

I am using: 
- MS Office Professional Plus 2010 
- Firefox 34.0.5 (I read Selenium doesn't work with higher versions of FF)
- Selenium IDE 2.4.0
- Selenium Wrapper 1.0.17.0
- Selenium Basic 2.0.9.0

I have recorded the following code in selenium IDE, outputted it to VBA script; however whenever I try running the code in VBA It trips up and stalls. 
___________________________________________________________________________
  Dim driver As New SeleniumWrapper.WebDriver
  Dim By As New By, Assert As New Assert, Verify As New Verify, Waiter As New Waiter
  driver.Start "firefox", "https://www.ebay.co.uk/"
  driver.setImplicitWait 5000

  driver.Get "/"
  driver.FindElementByLinkText("Sign in").Click
  driver.FindElementById("2031759456").Clear
  driver.FindElementById("2031759456").SendKeys USERNAME
  driver.FindElementById("707377953").Clear
  driver.FindElementById("707377953").SendKeys PASSWORD
  driver.FindElementById("sgnBt").Click
  driver.FindElementById("941057401").Clear
  driver.FindElementById("941057401").SendKeys PASSWORD
  driver.FindElementById("sgnBt").Click
  
  driver.stop
___________________________________________________________________________

I can't break out of the code and after a timeout period I get a message "Microsoft Excel is waiting for another application to complete an OLE action". I have to forcefully close Excel in task manager.

I've been trying a load of different things with no success. Can someone please help me?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/cc4add2f-610f-4ea3-9d36-15efd8e657aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAKwv7ZzXzOjzO%3DK3p1TNXJFps2f5x%3DEobjYi0O7xZ8BakBauMA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Automating Firefox using Selenium and VBA

thomas alexander lawford granger
In reply to this post by David
Hi David,

So I tried the link and I didn't get much further. I've downloaded the VBScript webdriver and it's just a handful of vbscript files. 

I know the programming language however I don't quite understand what I'm supposed to do with this. Would you be able to provide a bit more information into what I'm supposed to do next?

Sorry for my incompetence! This isn't something I'm familiar with.

Thanks
Tom

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/63fc607d-b2a9-4653-a071-e2c820d7e247%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Automating Firefox using Selenium and VBA

thomas alexander lawford granger
In reply to this post by Nilton da Silva
Hi Nilton,

Thank you for your message. If you're talking about the references in the tools tab of the vba editor then I have already enabled:

- SeleniumWrapper Type Library
- Selenium Type Library

Do I need anything else?

Thanks,
Tom

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/45b093c4-c922-4321-87ae-d38e0841a4a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Automating Firefox using Selenium and VBA

David
In reply to this post by thomas alexander lawford granger
For the VBScript webdriver, if you can call VBScript from VBA in Excel or Office apps, you can probably used it. I'd need to set up a demo myself sometime. You just need a way to "import" the code (like a library) to be able to call it in VBA, with the hacky way by copying & pasting the code into your VBA project. I think I recall long time back there's a method in VBScript (and thus VBA?) to read/load VB code into memory from file, which is equivalent of modern day library imports, and have used that before, don't have the exact info with me though.

Something like this: https://icodealot.com/dynamic-methods-in-vbscript/, if you can do similar in VBA, you can import the VBScript webdriver to then create an instance of it to work with.

On Tuesday, June 5, 2018 at 2:18:25 PM UTC-7, thomas alexander lawford granger wrote:
Hi David,

So I tried the link and I didn't get much further. I've downloaded the VBScript webdriver and it's just a handful of vbscript files. 

I know the programming language however I don't quite understand what I'm supposed to do with this. Would you be able to provide a bit more information into what I'm supposed to do next?

Sorry for my incompetence! This isn't something I'm familiar with.

Thanks
Tom

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e62c9792-f398-43a6-afaa-449adf03f349%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Automating Firefox using Selenium and VBA

Nilton da Silva
Eu acho que você está tentando criar uma maneira de logar no site, então eu coloquei para fazer isso, testá-lo e ver se funciona. Você precisa habilitar a Biblioteca de tipos de selênio para que funcione no menu Ferramentas na guia Referências




Dim driver como o Webdriver

Sub David ()

Definir driver = Novo ChromeDriver

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

driver.FindElementByLinkText ("Login"). Clique em
  driver.FindElementByXPath (".//*[@ id = 'userid']"). SendKeys ("UserName")
  
  
 driver.FindElementByXPath (".//*[@ id = 'pass']"). SendKeys ("Senha")
  driver.FindElementById ("sgnBt"). Clique em


  
   
  driver.Quit
  
  
End Sub


2018-06-06 21:57 GMT-03:00 David <[hidden email]>:
For the VBScript webdriver, if you can call VBScript from VBA in Excel or Office apps, you can probably used it. I'd need to set up a demo myself sometime. You just need a way to "import" the code (like a library) to be able to call it in VBA, with the hacky way by copying & pasting the code into your VBA project. I think I recall long time back there's a method in VBScript (and thus VBA?) to read/load VB code into memory from file, which is equivalent of modern day library imports, and have used that before, don't have the exact info with me though.

Something like this: https://icodealot.com/dynamic-methods-in-vbscript/, if you can do similar in VBA, you can import the VBScript webdriver to then create an instance of it to work with.

On Tuesday, June 5, 2018 at 2:18:25 PM UTC-7, thomas alexander lawford granger wrote:
Hi David,

So I tried the link and I didn't get much further. I've downloaded the VBScript webdriver and it's just a handful of vbscript files. 

I know the programming language however I don't quite understand what I'm supposed to do with this. Would you be able to provide a bit more information into what I'm supposed to do next?

Sorry for my incompetence! This isn't something I'm familiar with.

Thanks
Tom

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e62c9792-f398-43a6-afaa-449adf03f349%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAKwv7ZzVC%2BNRN_wU%2B51pY_pk_XiYskqY1Kau%3DEetUcbmtRVXtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Automating Firefox using Selenium and VBA

thomas alexander lawford granger
In reply to this post by David
Hi David,

Thank you for your reply. I've had a go with VBScript and I think I could do it with a bit of work, however I'm trying to keep everything within VBA. There are a few variable waiting periods and if the VBA code resumes for the VBScript has completed this could cause problems. I think it's adding additional complications into something that's already quite complex.

If you can provide any assistance with getting VBA to talk to Firefox that'd be fantastic!

Thanks,
Tom



On Thursday, 7 June 2018 01:57:17 UTC+1, David wrote:
For the VBScript webdriver, if you can call VBScript from VBA in Excel or Office apps, you can probably used it. I'd need to set up a demo myself sometime. You just need a way to "import" the code (like a library) to be able to call it in VBA, with the hacky way by copying & pasting the code into your VBA project. I think I recall long time back there's a method in VBScript (and thus VBA?) to read/load VB code into memory from file, which is equivalent of modern day library imports, and have used that before, don't have the exact info with me though.

Something like this: <a href="https://icodealot.com/dynamic-methods-in-vbscript/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ficodealot.com%2Fdynamic-methods-in-vbscript%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGBWweAWL9D7D_J9mqcfVxzA5pScg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ficodealot.com%2Fdynamic-methods-in-vbscript%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGBWweAWL9D7D_J9mqcfVxzA5pScg&#39;;return true;">https://icodealot.com/dynamic-methods-in-vbscript/, if you can do similar in VBA, you can import the VBScript webdriver to then create an instance of it to work with.

On Tuesday, June 5, 2018 at 2:18:25 PM UTC-7, thomas alexander lawford granger wrote:
Hi David,

So I tried the link and I didn't get much further. I've downloaded the VBScript webdriver and it's just a handful of vbscript files. 

I know the programming language however I don't quite understand what I'm supposed to do with this. Would you be able to provide a bit more information into what I'm supposed to do next?

Sorry for my incompetence! This isn't something I'm familiar with.

Thanks
Tom

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c609bda8-8285-4a10-bbdc-1bcd513d2209%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Automating Firefox using Selenium and VBA

thomas alexander lawford granger
In reply to this post by Nilton da Silva
Hi Nilton,

Your way is working, with a little tweaking. The code I recorded through selenium IDE doesn't work with VBA. it doesn't like the initial declaration of "Dim driver As New SeleniumWrapper.WebDriver"

So now I've got Firefox responding to VBA; however Firefox isn't loading up with the default profile. I use a proxy server with firefox so it's important Firefox opens with my settings. When Firefox opens it's a blank new user and it doesn't have my proxy settings.

I've tried setting the profile in VBA using the following code:

driver.SetProfile ("C:\Users\Tom\AppData\Local\Mozilla\Firefox\Profiles\a9itx68r.default")
driver.get "https://www.ebay.co.uk/", Raise = False

It ignores the profile and opens without any of the proxy setting etc.

Can you help here?

Thanks,
Tom

On Thursday, 7 June 2018 02:31:54 UTC+1, Nilton da Silva wrote:
Eu acho que você está tentando criar uma maneira de logar no site, então eu coloquei para fazer isso, testá-lo e ver se funciona. Você precisa habilitar a Biblioteca de tipos de selênio para que funcione no menu Ferramentas na guia Referências




Dim driver como o Webdriver

Sub David ()

Definir driver = Novo ChromeDriver

driver.get "<a href="https://www.ebay.co.uk/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.ebay.co.uk%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH0oJX8Tr1FckMrLQkVwZeQgKzz_A&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.ebay.co.uk%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH0oJX8Tr1FckMrLQkVwZeQgKzz_A&#39;;return true;">https://www.ebay.co.uk/"
Application.Wait Now + TimeValue ("00:00:01")

driver.FindElementByLinkText ("Login"). Clique em
  driver.FindElementByXPath (".//*[@ id = 'userid']"). SendKeys ("UserName")
  
  
 driver.FindElementByXPath (".//*[@ id = 'pass']"). SendKeys ("Senha")
  driver.FindElementById ("sgnBt"). Clique em


  
   
  driver.Quit
  
  
End Sub


2018-06-06 21:57 GMT-03:00 David <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="cfO0xb-AAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mang...@...>:
For the VBScript webdriver, if you can call VBScript from VBA in Excel or Office apps, you can probably used it. I'd need to set up a demo myself sometime. You just need a way to "import" the code (like a library) to be able to call it in VBA, with the hacky way by copying & pasting the code into your VBA project. I think I recall long time back there's a method in VBScript (and thus VBA?) to read/load VB code into memory from file, which is equivalent of modern day library imports, and have used that before, don't have the exact info with me though.

Something like this: <a href="https://icodealot.com/dynamic-methods-in-vbscript/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ficodealot.com%2Fdynamic-methods-in-vbscript%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGBWweAWL9D7D_J9mqcfVxzA5pScg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Ficodealot.com%2Fdynamic-methods-in-vbscript%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGBWweAWL9D7D_J9mqcfVxzA5pScg&#39;;return true;">https://icodealot.com/dynamic-methods-in-vbscript/, if you can do similar in VBA, you can import the VBScript webdriver to then create an instance of it to work with.

On Tuesday, June 5, 2018 at 2:18:25 PM UTC-7, thomas alexander lawford granger wrote:
Hi David,

So I tried the link and I didn't get much further. I've downloaded the VBScript webdriver and it's just a handful of vbscript files. 

I know the programming language however I don't quite understand what I'm supposed to do with this. Would you be able to provide a bit more information into what I'm supposed to do next?

Sorry for my incompetence! This isn't something I'm familiar with.

Thanks
Tom

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="cfO0xb-AAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">selenium-user...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="cfO0xb-AAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">seleniu...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/selenium-users/e62c9792-f398-43a6-afaa-449adf03f349%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/e62c9792-f398-43a6-afaa-449adf03f349%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/selenium-users/e62c9792-f398-43a6-afaa-449adf03f349%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/selenium-users/e62c9792-f398-43a6-afaa-449adf03f349%40googlegroups.com.

For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/4d387bac-0c15-492b-a441-0fed0e99a541%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.