2014-10-01 67 views
0

我有我寻觅的形式一个网页浏览器,我想看看,如果显示以下两个项目或不怎么看一个对象是否被阻塞在Vb.net的Webbrowser

<div class="alert alert-danger bet" style="display: block;">You Lost</div> 

<div class="alert alert-success bet" style="display: none;">You Won</div> 

和我找不到解决方案。我已经找到了如何搜索他们,并找到他们没有他们有一个ID,但我看不出风格。如果可能的话,我想现在将样式结果放在文本框中,直到我找出如何处理结果。

编辑

好了,所以这里就是我现在

Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("DIV") 
    For Each curElement As HtmlElement In theElementCollection 
     If curElement.OuterHtml.Contains("alert alert-danger bet") Then 
      TextBox1.Text = curElement.GetAttribute("style") 
     End If 
    Next 

这将返回System._ComObject,它似乎是我可以在所有返回的唯一的事情就是。 有什么建议吗?

回答

0

好的,所以最后我相信我有一个解决方案。

Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("DIV") 
For Each curElement As HtmlElement In theElementCollection 
    If curElement.OuterHtml.Contains("alert alert-danger bet") Then 
         If curElement.Style = "display: block;" Then 
       TextBox1.Text = "True" 
      ElseIf curElement.Style = "display: none;" Then 
       TextBox1.Text = "False" 
      End If 
     End If 
    Next 
    End If 
Next 

现在显然这只是显示我的一个项目,所以我仍然必须处理另一个,但至少这给了我一个真或假的陈述。

相关问题