Selenium. Is there a way to stop loading a web page in Chrome?

zgthgt

New Member
Joined
Oct 29, 2023
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hello to everybody here. I hope you are doing well.
Here is my task. I need to open a web page, find there a specific element, let's say some text. Then I need to copy the text to my worksheet. My code works, yet it takes way too long to open some web pages due to detected automation. I don't want my macros to load the whole page for 30 seconds, one second will be enough to get the information I need. Is there a way to stop loading the page just with VBA and Selenium? If not, is the a way to do it with VBA and some other software?

Thank you in advance

VBA Code:
Option Explicit
Private cd As Selenium.ChromeDriver
Public Sub Copy()

Dim i As Integer 'just a counter
Set cd = New Selenium.ChromeDriver
cd.Start
cd.Get ("....") 'loading a webpage, takes way too long
Dim Headlines As Selenium.WebElements
Dim Headline As Selenium.WebElement

Set Headlines = cd.FindElementsByClass("lpl-1")
i = 1
For Each Headline In Headlines
ThisWorkbook.Sheets("Sheet1").Cells(1, i).Value = Headline.Text
i = i + 1
Next Headline

End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top