Trying to automate a web-page to fill form. I have an issue where i need to keep entering data according to excel sheet.
So, if i have 2 rows of data in excel i need to click "Add Row" button in the web-page and then fill the form accordingly. And if i have 3 rows in excel, then i need to click twice on "Add Row" button web-page and then fill it.
The approach here (what i have done) is to click the "Add Row" button firstly according to number provided by the user in any cell beforehand. And then fill out the form.
But this does not seem to work.
If ThisWorkbook.Worksheets("Annexure").Range("G8").Value = 2 Then
bot.FindElementByXPath("//a[@class='add btn-add-raw-materials action']//i[@class='fa fa-plus-circle']").Click
ElseIf ThisWorkbook.Worksheets("Annexure").Range("G8").Value = 3 Then
bot.FindElementByXPath("//a[@class='add btn-add-raw-materials action']//i[@class='fa fa-plus-circle']").Click
bot.FindElementByXPath("//a[@class='add btn-add-raw-materials action']//i[@class='fa fa-plus-circle']").Click
ElseIf ThisWorkbook.Worksheets("Annexure").Range("G8").Value = 4 Then
bot.FindElementByXPath("//a[@class='add btn-add-raw-materials action']//i[@class='fa fa-plus-circle']").Click
bot.FindElementByXPath("//a[@class='add btn-add-raw-materials action']//i[@class='fa fa-plus-circle']").Click
bot.FindElementByXPath("//a[@class='add btn-add-raw-materials action']//i[@class='fa fa-plus-circle']").Click
ElseIf ThisWorkbook.Worksheets("Annexure").Range("G8").Value = 5 Then
bot.FindElementByXPath("//a[@class='add btn-add-raw-materials action']//i[@class='fa fa-plus-circle']").Click
bot.FindElementByXPath("//a[@class='add btn-add-raw-materials action']//i[@class='fa fa-plus-circle']").Click
bot.FindElementByXPath("//a[@class='add btn-add-raw-materials action']//i[@class='fa fa-plus-circle']").Click
bot.FindElementByXPath("//a[@class='add btn-add-raw-materials action']//i[@class='fa fa-plus-circle']").Click
End If
bot.FindElementById("export-HS-code").SendKeys ThisWorkbook.Worksheets("Annexure").Range("B11")
bot.FindElementById("raw-material-description-1").SendKeys ThisWorkbook.Worksheets("Annexure").Range("C11")
bot.FindElementById("raw-material-quantity-unit-1").SendKeys ThisWorkbook.Worksheets("Annexure").Range("D11")
bot.FindElementByName("raw_material_unit[1]").SendKeys ThisWorkbook.Worksheets("Annexure").Range("E11")
bot.FindElementById("raw-material-unit-cif-value-1").SendKeys ThisWorkbook.Worksheets("Annexure").Range("F11")
bot.FindElementById("raw-material-total-cif-value-1").SendKeys ThisWorkbook.Worksheets("Annexure").Range("G11")
bot.FindElementByName("raw_country_id[1]").SendKeys ThisWorkbook.Worksheets("Annexure").Range("H11")
bot.FindElementById("bill-invoice-no-1").SendKeys ThisWorkbook.Worksheets("Annexure").Range("I11")
bot.FindElementById("bill-invoice-date-1").SendKeys ThisWorkbook.Worksheets("Annexure").Range("J11")
bot.FindElementById("supplier-details-1").SendKeys ThisWorkbook.Worksheets("Annexure").Range("K11")
I know this is not a good way of doing it, because what if i need to click the "Add Row" 10-20 times, this code will not be an efficient way.
Thus asking for help here. Thanks in advance