BasitAmeer
New Member
- Joined
- Nov 23, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- 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:
I hope this is understandable...
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