运行时错误'0':使用Selenium,vba和css选择器单击按钮的SeleniumError无效参数

邓弗莱斯

我试图单击网页上的按钮,并不断出现以下错误(对不起,显然不能嵌入图像,否则我将在此处截屏)

运行时错误'0':SeleniumError无效参数

该按钮的Http为

<input type="file" name="import_file" id="import_file" accept=".csv, text/csv">

我已经尝试过bot.FindElementById("import_file").Click,并且返回了相同的错误,所以我尝试使用名称,同样的错误。

我刚刚尝试过bot.FindElementByCss("input#import_file[type='file'][name='import_file'][accept='.csv, text/csv']").Click,并且返回相同的错误...

不知道下一步该怎么做;有任何想法吗?我的整个子文件夹都在下面供参考(带有密码等,明显被覆盖)

Sub import_csv()

Dim bot As New WebDriver

bot.Start "chrome", "https://website.com"
bot.Get "/"

'log in
bot.FindElementById("user_login").SendKeys ("####")
bot.FindElementById("user_password").SendKeys ("####")
bot.FindElementByName("commit").Click

'navigate to import screen
bot.Get ("/stocks/import_stocks")

'tick 'File has header row?'
bot.FindElementById("file_has_header").Click

'Click 'Browse...' to open import screen - this is where something isn't working
bot.FindElementByCss("input#import_file[type='file'][name='import_file'][accept='.csv, text/csv']").Click

'import
bot.FindElementByName("commit").Click
bot.SendKeys ("C:\Users\Duane Humphreys\Documents\calendar.CSV")
bot.SendKeys bot.Keys.Enter
bot.FindElementByName("commit").Click

End Sub

编辑:如果要有用,围绕我要单击的按钮的html在下面:

<span class="l-inline-row-block form-file">
          <span class="l-inline-col" style="width: 110px;">
            <a class="btn-medium btn-alt form-file-btn">
              Browse… <input type="file" name="import_file" id="import_file" accept=".csv, text/csv">
            </a>
          </span>
          <span class="l-inline-col">
            <input type="text" readonly="">
          </span>
        </span>
邓弗莱斯

我不认为这可以解决这里发生的一切的根本原因,但是我设法解决了

bot.FindElementById("import_file").ClickAndHold
bot.SendKeys bot.Keys.Enter

我仍然不知道为什么.ClickAndHold工作和.click不,但这将会对现在的工作。LMK,如果有一种更干净的方法来实现相同的目标。

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

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

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

除以0是编译器错误或运行时错误

PyTorch运行时错误:参数无效0:张量的大小必须匹配,但维度1除外

无法在模拟器中运行应用程序:运行时遇到错误(域= LaunchServicesError,代码= 0)

Qt在Android运行时错误:获取资源号0x00000000的包时无效的包标识符

0x800a139e-JavaScript运行时错误:[ng:areq]参数'timesheetListCtrl'不是函数,未定义

状态为0的响应:URL:null –在模拟器或Web中运行时出现此错误

0xc000007b 错误和 Microsoft Visual C++ 2010 x86 运行时

运行时错误,输入的形状无效

提交按钮运行时错误13

运行时错误VBS / VBA

运行时错误13 VBA Excel

VBA宏上的运行时错误

Excel VBA运行时错误1004

VBA - 运行时错误“1004”

VBA - 运行时错误“-2147024894 (80070002)”

质数查找器运行时错误

换位和置换-运行时错误

MediaPlayer和imagebutton的运行时错误

运行时错误1004和424

VBA 帮助 - 运行时错误 5:无效的过程调用或参数,仅在首次运行时

使用.PasteSpecial的运行时错误'438'

使用OnTouchListenner的Android运行时错误

0x800a01b6-JavaScript运行时错误:对象不支持属性或方法“时间选择器”

找不到列[0]运行时错误

无效的过程调用或参数vba。运行时错误5

运行“粘贴”时,出现VBA运行时错误438

Excel VBA:运行时错误(对象“范围”的方法“值”失败),但仅在连续运行时

0:0:0中的运行时错误错误,原因是:没有StatusBar提供程序

VBA Excel 错误运行时错误“53”