无法使用Selenium VBA在Chrome中循环Excel数据

阿米特·莎(Amit Shah)

我发现循环功能困难,即。从Excel工作表中获取值并执行任务。我有这个网站:http : //dgftebrc.nic.in : 8100/BRCQueryTrade/index.jsp,其中我需要输入IEC代码:

  1. 0906008051
  2. 0906008069

以后输入

装运单号:

  1. 3929815
  2. 3953913
  3. 3979509

我的意思是目前我已经进行了硬编码,但是由于我拥有大量数据并且无法以硬编码方式编写它,因此我无法使其循环运行,因为对于1个IEC编号,我大约有1000 SB。因此可以有100个IEC编号,因此有许多发货单编号(SB.no)。

使用我已解决的标签,但随后使用多个发货单号却导致我遇到问题。

我可以管理这么多的代码:

Option Explicit

Public Sub multipletabtest()

Dim bot As WebDriver
Dim keys As New Selenium.keys
Dim count As Long

Set bot = New WebDriver
bot.Start "Chrome"
'count = 1
'While (Len(Range("A" & count)) > 0)

bot.Get "http://dgftebrc.nic.in:8100/BRCQueryTrade/index.jsp"

bot.FindElementByXPath("//input[@type='text'][@name='iec']").SendKeys "0906008051"
bot.FindElementByXPath("//input[@type='text'][@name='sno']").SendKeys "3929815"
bot.Wait 10000         'Time to enter the captcha

bot.FindElementByCss("[value='Show Details']").SendKeys keys.Control, keys.Enter          'Take the value from final result sheet
bot.SwitchToNextWindow

ThisWorkbook.Sheets("Sheet1").Range("B1") = bot.FindElementByXPath("//text()[.='Used']/ancestor::td[1]").Text
'Range("B" & count) = bot.FindElementByXPath("//text()[.='Used']/ancestor::td[1]").Text  'To extract the data
'bot.Window.Close


bot.SwitchToPreviousWindow
bot.FindElementByXPath("//input[@type='text'][@name='sno']").Clear

bot.FindElementByXPath("//input[@type='text'][@name='sno']").SendKeys "3953913"
bot.FindElementByCss("[value='Show Details']").SendKeys keys.Control, keys.Enter
bot.SwitchToNextWindow

ThisWorkbook.Sheets("Sheet1").Range("B2") = bot.FindElementByXPath("//text()[.='Used']/ancestor::td[1]").Text
'Range("B" & count) = bot.FindElementByXPath("//text()[.='Used']/ancestor::td[1]").Text


'count = count + 1
'Wend
bot.Quit
End Sub

而且因为如果有人想知道为什么按Ctrl + Enter键,那是因为验证码仍然是其他运输法案不相同,所以选择了这个方法。

我也尝试了while语句,但是提取的数据被复制了两次。

看图片

阿米特·莎(Amit Shah)
Option Explicit
Public Sub multipletabtest()

Dim bot As WebDriver
Dim keys As New Selenium.keys
Dim count As Long

Set bot = New WebDriver
bot.Start "Chrome"
bot.Get "http://dgftebrc.nic.in:8100/BRCQueryTrade/index.jsp"

count = 1
While (Len(Range("A" & count)) > 0)


bot.FindElementByXPath("//input[@name='iec']").SendKeys Range("A" & count)
bot.FindElementByXPath("//input[@name='sno']").SendKeys Range("B" & count)

bot.Wait 10000         'Time to enter the Captcha


bot.FindElementByCss("[value='Show Details']").SendKeys keys.Control, keys.Enter
bot.SwitchToNextWindow


If bot.FindElementsByXPath("//tr[2]//td[7]").count > 0 Then
Range("C" & count) = bot.FindElementByXPath("//tr[2]//td[7]").Text

If bot.FindElementsByXPath("//p[contains(text(),'No Data Found.....check the Input Parameters')]").count > 0 Then
Range("C" & count) = "No Data"


End If
End If
bot.Window.Close

bot.SwitchToPreviousWindow
bot.FindElementByXPath("//input[@type='text'][@name='sno']").Clear


count = count + 1
Wend

bot.Quit
End Sub

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Selenium:无法在 Selenium 中使用 for 循环上传文件

来自分类Dev

使用SendKeys时,元素无法与Selenium Excel VBA交互

来自分类Dev

使用Selenium的Excel VBA

来自分类Dev

Excel VBA函数使用“ FOR”循环来计算多列数据并将其显示在用户窗体中

来自分类Dev

Chrome无法使用Selenium Python打开配置文件

来自分类Dev

使用Selenium Python无法以表格形式获取数据

来自分类Dev

使用VBA代码在Excel中查找循环链接

来自分类Dev

Selenium Webdriver无法在Firefox 24.0中使用DOM元素

来自分类Dev

我无法使用python在Selenium中向下滚动

来自分类Dev

无法使用ruby在Selenium WebDriver中获取HAR文件

来自分类Dev

无法使用Selenium WebDriver在文本框中输入值

来自分类Dev

无法使用 selenium webdriver 在 Gmail 中单击撰写按钮

来自分类Dev

无法通过 Selenium 使用 ember 定位 iframe 中的元素

来自分类Dev

无法使用for循环(Apache_poi)在Excel工作表中写入数据

来自分类Dev

无法使用for循环(Apache_poi)在Excel工作表中写入数据

来自分类Dev

无法使用VBA,Excel在公式中添加=

来自分类Dev

Excel VBA:无法使用 if 语句和 for 循环删除多列

来自分类Dev

无法使用Java / Selenium将元素集中在Chrome和Edge中

来自分类Dev

无法使用Selenium Webdriver将解压后的扩展程序加载到Chrome中

来自分类Dev

无法使用Selenium Webdriver将解压后的扩展程序加载到chrome中

来自分类Dev

无法使用 Selenium 中的用户配置文件启动 Chrome 浏览器

来自分类Dev

无法使用Java从Selenium Webdriver中的Excel工作表中获取数值

来自分类Dev

使用 Selenium VBA 切换回 chrome 中的父窗口

来自分类Dev

使用数组中的数据在循环中运行selenium函数

来自分类Dev

使用 Selenium + VBA 在浏览器中粘贴 Excel 范围

来自分类Dev

selenium.common.exceptions.WebDriverException:消息:未知错误:无法使用ChromeDriver Chrome Selenium创建Chrome进程错误

来自分类Dev

无法使用C#使用Selenium WebDriver以隐身模式启动Chrome

来自分类Dev

无法在 Testcontainers 中使用 Chrome 驱动程序使用 Selenium 打开任何 URL

来自分类Dev

使用VBA格式化Excel图表中的数据标签

Related 相关文章

  1. 1

    Selenium:无法在 Selenium 中使用 for 循环上传文件

  2. 2

    使用SendKeys时,元素无法与Selenium Excel VBA交互

  3. 3

    使用Selenium的Excel VBA

  4. 4

    Excel VBA函数使用“ FOR”循环来计算多列数据并将其显示在用户窗体中

  5. 5

    Chrome无法使用Selenium Python打开配置文件

  6. 6

    使用Selenium Python无法以表格形式获取数据

  7. 7

    使用VBA代码在Excel中查找循环链接

  8. 8

    Selenium Webdriver无法在Firefox 24.0中使用DOM元素

  9. 9

    我无法使用python在Selenium中向下滚动

  10. 10

    无法使用ruby在Selenium WebDriver中获取HAR文件

  11. 11

    无法使用Selenium WebDriver在文本框中输入值

  12. 12

    无法使用 selenium webdriver 在 Gmail 中单击撰写按钮

  13. 13

    无法通过 Selenium 使用 ember 定位 iframe 中的元素

  14. 14

    无法使用for循环(Apache_poi)在Excel工作表中写入数据

  15. 15

    无法使用for循环(Apache_poi)在Excel工作表中写入数据

  16. 16

    无法使用VBA,Excel在公式中添加=

  17. 17

    Excel VBA:无法使用 if 语句和 for 循环删除多列

  18. 18

    无法使用Java / Selenium将元素集中在Chrome和Edge中

  19. 19

    无法使用Selenium Webdriver将解压后的扩展程序加载到Chrome中

  20. 20

    无法使用Selenium Webdriver将解压后的扩展程序加载到chrome中

  21. 21

    无法使用 Selenium 中的用户配置文件启动 Chrome 浏览器

  22. 22

    无法使用Java从Selenium Webdriver中的Excel工作表中获取数值

  23. 23

    使用 Selenium VBA 切换回 chrome 中的父窗口

  24. 24

    使用数组中的数据在循环中运行selenium函数

  25. 25

    使用 Selenium + VBA 在浏览器中粘贴 Excel 范围

  26. 26

    selenium.common.exceptions.WebDriverException:消息:未知错误:无法使用ChromeDriver Chrome Selenium创建Chrome进程错误

  27. 27

    无法使用C#使用Selenium WebDriver以隐身模式启动Chrome

  28. 28

    无法在 Testcontainers 中使用 Chrome 驱动程序使用 Selenium 打开任何 URL

  29. 29

    使用VBA格式化Excel图表中的数据标签

热门标签

归档