有人可以建议如何“点击” ALPHA吗?
public override LexResponse Process(LexEvent lexEvent, ILambdaContext context)
{
var slots = lexEvent.CurrentIntent.Slots;
var sessionAttributes = lexEvent.SessionAttributes ?? new Dictionary<string, string>();
DesiredVehicleYesNo type;
if (slots.ContainsKey("DesiredVehicleYesNo"))
{
Enum.TryParse(slots["DesiredVehicleYesNo"], out type);
}
else
{
type = DesiredVehicleYesNo.Null;
}
switch (type)
{
case DesiredVehicleYesNo.YES:
Dictionary<string, string> s = new Dictionary<string, string>();
s.Add("DesiredVehicle", null);
//return ConfirmIntent(sessionAttributes, "DesiredVehicleYes", s, new LexResponse.LexMessage() { Content = "That's great! Let's get started.", ContentType = MESSAGE_CONTENT_TYPE });
//return ElicitSlot(sessionAttributes,"DesiredVehicleYes",null,"DesiredVehicle", new LexResponse.LexMessage() { Content = "That's great! Let's get started.", ContentType = MESSAGE_CONTENT_TYPE });
case DesiredVehicleYesNo.NO:
return ConfirmIntent(sessionAttributes, "DesiredVehicleNo", new Dictionary<string,string>(), new LexResponse.LexMessage() { Content = "Well, that's ok, I can help you choose", ContentType = MESSAGE_CONTENT_TYPE });
}
我尝试了多种不同的方法,但是似乎没有任何作用,例如
</td>
<td class="center"><a href="#" onclick="javascript:doSubmit('Edit-1');" title="ALPHA">
ALPHA
</a>
<input type="hidden" id="Org1" value="ALPHA"/>
或
IE.Document.GetElementsByClassName("ALPHA")(0).Click
或
IE.Document.GetElementsByTagName("ALPHA")(0).Click
以及
.Document.all.Item("Org1").Value = "ALPHA"
.Document.GetElementsByClassName("ALPHA")(0).Click
.Visible = True
答案 0 :(得分:2)
尝试
ie.document.querySelector("a[title=ALPHA]").Click
值得注意的是,我们无法从提供的HTML中看到是否存在要导航的父表单/框架/ iframe标签。如果有的话,您将需要更新提供的HTML来显示这些内容。
这应用了CSS选择器来定位元素。它会寻找带有a
标签的元素,该元素的属性为title
,其值为ALPHA
。
答案 1 :(得分:1)
浏览所有锚点(即A)标记,并找到带有正确的.innerText或.title的标记。
for each obj in IE.Document.GetElementsByTagName("A")
if obj.title = "ALPHA" or obj.innertext = "ALPHA" then
obj.click
exit for
end if
next obj
您可以通过仅循环遍历该表中的锚标记而不是整个文档来减少循环。