Awesomium获取并单击“标签"属性 [英] Awesomium Getting and clicking a Tags attribute
问题描述
按标签名称和属性单击按钮时遇到问题.我可以使用以下按钮类来单击它:
I'm having an issue clicking a button by the tag name and attribute. I can click it using the buttons class with the following:
public void Event(string getElementQuery, string eventName)
{
Control.ExecuteJavascript(@"
function fireEvent(element,event) {
var evt = document.createEvent('HTMLEvents');
evt.initEvent(event, true, false ); // event type,bubbling,cancelable
element.dispatchEvent(evt);
}
" + String.Format("fireEvent({0}, '{1}');", getElementQuery, eventName));
}
private void Reload_Tick(object sender, EventArgs e)
{
Event("document.getElementsByClassName('Reload')[0]", "click");
}
这很好,但是有时候我有一个按钮可以重新加载类.我想使用标记a和属性RELOAD更好地定义它,我尝试了以下方法,但是它什么也没做:
That's fine and all But sometimes I have more then one button with the class reload. I would like to define it better using the tag being a and the attribute being RELOAD I have tried it with the following but it does nothing at all:
Event("document.getElementsByTagName('a').getAttribute('RELOAD')[0]", "click");
这有效,但是单击了错误的按钮,这就是为什么我也需要该属性的原因.
This works but it clicks the wrong button, which is why i need the attribute also.
Event("document.getElementsByTagName('a')[0]", "click");
但是当我尝试获取属性时,什么也没有发生.有人可以帮我吗.
But when I try getting the attribute nothing happens. Could someone help me out please.