我试图在VBA中使用Selenium自动单击网站上的展开按钮(领结)-最终将所有表数据导入excel。
我能够遍历每一行代码,并且行为正确,除了最后一行,当我尝试选择隐藏的领结(图片中的最大化按钮)时,我收到运行时错误“ 32” :应用程序定义或对象定义的错误。
bot.FindElementByClass("richeditor-toolbar-button workitem-group-maximize").Click
我使用了检查领结时提供的确切类-也尝试了其他类),但是当我按f8键时-会话终止并且弹出错误。
任何想法可能是什么原因造成的?
Sub automation() Dim bot As New ChromeDriver, menuitem As WebElement
bot.Get "https://company.visualstudio.com/"
Set menuitem = bot.FindElementById("ui-id-38")
bot.Actions.MoveToElement(menuitem).Perform
bot.FindElementByClass("richeditor-toolbar-button workitem-group-maximize").Click
screenshot of inspected bowtie element run time error screenshot
编辑-进行了更多操作,发现从类选择器中删除最后一个“ div”使其起作用。添加代码屏幕快照以供参考-这是一个Intranet网站,因此如果没有公司的设备就无法登录-屏幕快照2显示了我正在尝试最大化的检查元素。
我在下面尝试了此版本,因为其他部分的页面上有多个领结版本,删除了最后一个div即可。
由于末尾的div,这不起作用
bot.FindElementByCss("#vss_390 > div.tfs-collapsible-header.wit-form-group-header > button >div"
下面的方法是由于删除了div末尾处的内容,尽管不确定为什么会这样
Set menuitem = bot.FindElementById("ui-id-38")
bot.Actions.MoveToElement(menuitem).Perform
bot.FindElementByCss("#vss_390 > div.tfs-collapsible-header.wit-form-group-header > button").Click
我尝试与HTML Reference一起使用的页面的HTML参考