This issue has been bugging me for more than 3 months now. I have tried to add proxy through list and as a manual IP, but the setting is simply bypassed, leading to no change in IP. The code:
Set mybrowser = New ChromeDriver
Set mybrowser2 = New ChromeDriver
With mybrowser
.Start
.Proxy.SetSocksProxy ("45.140.13.119:9132")
.Get ("https://whatismyipaddress.com")
End with
Related
I have VBA code that enters www.ibm.com.
There is a cookies consent window I want to bypass.
]1
I tried to click on the accept button by Xpath but I get error.
Run-time Error 7:
NoSuchElementError
Element not found for XPath=/html/body/div[8]/div[1]/div/div[3]/a[1]
rendered error message
I tried to wait until it fully loads, but still no success.
Here is my attempt:
Dim driver
Set driver = CreateObject("Selenium.EdgeDriver")
With driver
.start
.get "https://ibm.com"
.FindElementByXPath("/html/body/div[8]/div[1]/div/div[3]/a[1]").Click
.Quit
End With
I found something about a switch to frame but I do not know how to perform.
your button is inside a frame, so you could something like this:
Sub CloseConsent()
With New ChromeDriver
.get "http://hcad.org/quick-search/"
.SwitchToFrame .FindElementByXPath("//iframe[#class='truste_popframe']", timeout:=10000)
.FindElementByXPath("//a[#class='call']", timeout:=10000).Click
End With
End Sub
I'd like to open a new Chromedriver session with a selected profile "Profile 1". But I also want to keep other Chrome window/session open (which has the default profile).
I tried this piece of code, it opens the new Chrome windows correctly and with "Profile 1" as I want.
But I then get following error from VBA.
Private Sub Use_Chrome_With_Custom_profile_name()
' Profiles folder : %APPDATA%\Google\Chrome\Profiles
' Note that with Chrome the profile is always persistant
Dim driver As New ChromeDriver
driver.AddArgument "--user-data-dir=C:\Users\user1\AppData\Local\Google\Chrome\User Data"
driver.AddArgument "--profile-directory=Profile 1"
driver.Get "https://www.google.co.uk"
driver.Quit
End Sub
If I skip (commenting it) this line then Chrome does'nt open with Profile 1:
'driver.AddArgument "--user-data-dir=C:\Users\user1\AppData\Local\Google\Chrome\User Data"
Try this:
Dim driver As New WebDriver
Const URL = "https://www.google.co.uk"
Const JS_PROFILE As String = _
"C:\Users\user1\AppData\Local\Google\Chrome\User Data\Profile 1"
Set driver = New ChromeDriver
With driver
.SetProfile JS_PROFILE, True
.Get URL
End With
Trying to click a download button on Chrome using Selenium Type Library. The code below is one that I picked up off the boards but I am receiving a Syntax Error
Sub Test()
Dim bot
Set bot = CreateObject("Selenium.WebDriver")
bot.Start "Chrome", "https://www.afterpaytouch.com"
bot.get "/results-reports"
bot.findElement(By.linkText("https://www.afterpaytouch.com/images/28082019-FY2019-Results-Presentation.pdf")).click()
End Sub
I would add a reference to Selenium Type Library in VBE > Tools > References then use early bound reference, full url and apply VBA selenium basic syntax to find link by css and click
Option Explicit
Public Sub Test()
Dim bot As WebDriver
Set bot = New ChromeDriver
With bot
.Start "Chrome"
.get "https://www.afterpaytouch.com/results-reports"
.FindElementByCss("[href='https://www.afterpaytouch.com/images/28082019-FY2019-Results-Presentation.pdf']").Click
Stop '<delete me later
End With
End Sub
I've created a script in vba in combination with selenium to parse the first headline from this webpage. Most of the times my script throws this error timeout or this error Run-time error 21; Application defined or Object defined error while sometimes it works flawlessly. As the page takes too much time to load it's content, I suppose I'm having one of the side effect of a slow loading page, so I wish to disable images from that page.
I've tried with:
Sub TestSelenium()
Const URL$ = "https://www.marketscreener.com/"
Dim driver As Object, post As Object
Set driver = New ChromeDriver
driver.get URL
Set post = driver.FindElementByCss(".une_title")
MsgBox post.Text
driver.Quit
End Sub
When I go for python selenium binding, I can use this option to disable images:
option = webdriver.ChromeOptions()
chrome_prefs = {}
option.experimental_options["prefs"] = chrome_prefs
chrome_prefs["profile.default_content_settings"] = {"images": 2}
chrome_prefs["profile.managed_default_content_settings"] = {"images": 2}
driver = webdriver.Chrome(options=option)
I know there are options to set different preferences in vba but in case of disabling images I can't find any proper way to set them:
driver.SetPreference
driver.AddArgument
How can I set chrome preferences in vba selenium to let the page load quickly without images?
To disable images from that page, this is how you can set the preference within vba selenium bindings:
driver.SetPreference "profile.managed_default_content_settings.images", 2
Your script looks like the following when you implement the above suggestion:
Sub TestSelenium()
Const URL$ = "https://www.marketscreener.com/"
Dim driver As Object, post As Object
Set driver = New ChromeDriver
driver.SetPreference "profile.managed_default_content_settings.images", 2
driver.get URL
Set post = driver.FindElementByCss(".une_title")
MsgBox post.Text
Stop
driver.Quit
End Sub
You could always try running it headless? That should remove any delay associated with image loading.
driver.AddArgument "--headless"
So I am tryin to create a Script that will automatically login for me on this website:
https://teespring.com/login
This is my script so far:
Sub openBrowser()
'Open new browser
Set driver = New Selenium.ChromeDriver
'Navigate to Website
urlWebsite = "https://teespring.com/login"
driver.Get urlWebsite
So I have tried to enter my username with the following lines of code:
driver.FindElementByCss("").sendKeys Username
But I got an error saying element not visible
Is there any way I can still automate the login process?
thanks for your help and if you need further information I will try my best to as I am still learning how to handle vba selenium :-)
It is not visible because it is inside a form.
You need to access via form:
Option Explicit
Public Sub EnterInfo()
Dim d As WebDriver
Set d = New ChromeDriver
Const URL = "https://teespring.com/login"
With d
.Start "Chrome"
.get URL
With .FindElementByClass("js-email-login-form")
.FindElementByCss("input[name=email]").SendKeys "myEmail"
.FindElementByCss("input[name=password]").SendKeys "myPassWord"
.FindElementByCss("input[type=submit]").Click
End With
Stop '<== Delete me after inspection
.Quit
End With
End Sub