How to increment cell (A2 to A3..A4..) and so on using selenium macros excel.

BasitAmeer

New Member
Joined
Nov 23, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello Experts, I'm working on my script to automize the product adding from an excel sheet to an online web form. but, I can't able to move from row to row like (A1 to A2). Any help will be highly appreciated.

Below the code of the selenium macros:
Code:
Option Explicit
Dim Mychrome As Selenium.ChromeDriver
Sub Connect_To_Existing_chrome_Browser_Session()

Dim Dict_Capib As Variant
Set Mychrome = New Selenium.ChromeDriver
Mychrome.Get "https://pakeeza-backend-railway-production.up.railway.app/admin/auth/login"
Application.Wait DateAdd("s", 8, Now)
'Mychrome.Window.Maximize
'Dim ddl As Selenium.SelectElement
Dim a, i, count As Integer
Dim C, cc As Range
a = 10
Mychrome.SetCapability "debuggerAddress", "localhost:65444"


' login credential
Mychrome.FindElementByName("email").SendKeys ("xxxxxxxxx@gmail.com")
Application.Wait DateAdd("s", 2, Now)
Mychrome.FindElementByName("password").SendKeys ("***********")
Application.Wait DateAdd("s", 2, Now)


' login button
Mychrome.FindElementByXPath("//body/div[@id='app']/div[2]/div[1]/main[1]/div[1]/form[1]/div[2]/button[1]").Click
Application.Wait DateAdd("s", 8, Now)
Mychrome.FindElementByXPath("//span[contains(text(),'Content Manager')]").Click
Application.Wait DateAdd("s", 10, Now)
Mychrome.FindElementByXPath("//span[contains(text(),'Product')]").Click
Application.Wait DateAdd("s", 5, Now)


' click on new entry
While (Len(Range("1" & count)) > 0) ' I try this one but not working :(

Mychrome.FindElementByXPath("//a[@class='sc-ieecCq corbuY sc-dlVxhl gTJxgr'][1]").Click
Application.Wait DateAdd("s", 5, Now)
    
' upload name
Mychrome.FindElementByName("Name").SendKeys Range("A" & count)
Application.Wait DateAdd("s", 2, Now)
    
' upload model
Mychrome.FindElementByName("Model").SendKeys (ThisWorkbook.Sheets("dawlance").Range("B2").Value)
Application.Wait DateAdd("s", 2, Now)
' upload price


Mychrome.FindElementById("Price").SendKeys (ThisWorkbook.Sheets("dawlance").Range("C2").Value)
Application.Wait DateAdd("s", 2, Now)
' upload amount


Mychrome.FindElementById("Amount").SendKeys (ThisWorkbook.Sheets("dawlance").Range("D2").Value)
Application.Wait DateAdd("s", 2, Now)


' upload image
Mychrome.FindElementByXPath("//span[contains(text(),'Click to add an asset or drag and drop one in this')]").Click
Application.Wait DateAdd("s", 2, Now)

' Add asset
Mychrome.FindElementByXPath("/html[1]/body[1]/div[9]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[2]/button[2]").Click
Application.Wait DateAdd("s", 5, Now)


' select url
Mychrome.FindElementByXPath("//span[contains(text(),'From url')]").Click
Application.Wait DateAdd("s", 2, Now)


' click url text box
Mychrome.FindElementByName("urls").Click
Application.Wait DateAdd("s", 2, Now)


' upload link
Mychrome.FindElementByName("urls").SendKeys (ThisWorkbook.Sheets("dawlance").Range("E2").Value)
Application.Wait DateAdd("s", 2, Now)


'next button
Mychrome.FindElementByXPath("//body/div[9]/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]/div[1]/form[1]/div[2]/div[1]/div[2]/button[1]").Click
Application.Wait DateAdd("s", 3, Now)


'click to uploaded
Mychrome.FindElementByXPath("/html[1]/body[1]/div[9]/div[1]/div[1]/div[1]/div[1]/form[1]/div[3]/div[1]/div[2]/button[1]").Click
Application.Wait DateAdd("s", 3, Now)


'click to finished
Mychrome.FindElementByXPath("/html[1]/body[1]/div[9]/div[1]/div[1]/div[1]/div[1]/div[3]/div[1]/div[2]/button[1]").Click
Application.Wait DateAdd("s", 3, Now)


' save button
Mychrome.FindElementByXPath("//body/div[@id='app']/div[2]/div[1]/div[1]/div[1]/div[1]/form[1]/main[1]/div[2]/div[1]/div[2]/div[1]/div[1]/button[2]").Click
Application.Wait DateAdd("s", 5, Now)


' product page
Mychrome.FindElementByXPath("/html[1]/body[1]/div[1]/div[2]/div[1]/div[1]/div[1]/nav[1]/div[2]/ol[1]/li[1]/div[1]/ol[1]/li[4]/a[1]/div[1]/div[1]/span[1]").Click


Wend

'Lets capture 5 digits port number from new chrome driver session
'Dict_Capib = Mychrome.Manage.Capabilities.Values
'Fetch the port Number'Debug.Print Mychrome.Manage.Capabilities("goog: chromeOptions").Item("debuggerAddress")
End Sub
I hope this is understandable...
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
1669240024321.png
 
Upvote 0

Forum statistics

Threads
1,224,812
Messages
6,181,105
Members
453,021
Latest member
Justyna P

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