excel - 单击“添加行”后如何处理动态行
问题描述
试图自动化一个网页来填写表格。我有一个问题,我需要根据 Excel 表继续输入数据。
因此,如果我在 excel 中有 2 行数据,我需要单击网页中的“添加行”按钮,然后相应地填写表格。如果我在 excel 中有 3 行,那么我需要在“添加行”按钮网页上单击两次,然后填写它。
这里的方法(我所做的)是首先根据用户在任何单元格中提供的数字首先单击“添加行”按钮。然后填写表格。
但这似乎不起作用。
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")
我知道这不是一个好方法,因为如果我需要点击“添加行”10-20 次,这段代码将不是一个有效的方法。
因此在这里寻求帮助。 提前致谢
解决方案
推荐阅读
- sas - 为什么人们在 SAS 中使用只有一个参数的 min/max 函数
- python - ValueError:Series 的真值不明确。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()。IF 语句
- php - 无法删除括号中的值并更新值
- c# - 使用 C# 进行 JSON 解析
- javascript - Vue 3 + vue-i18n-next:我做错了什么?
- javascript - Vue 3 i18n 问题:此版本不支持消息格式编译
- python - 我想了解 echedule.every().day.at 如何与另一个线程并行
- java - 无法在我的视图上显示数据:评估 SpringEL 表达式的异常
- powershell - 将数组传递到哈希表,单项数组失败
- mysql - #1292 - 截断不正确的 DOUBLE 值: