最新のSelenium RC Python ClientとSelenium RC Serverを使用しています。FirefoxとIEでonclickを含むSelenium CSS Locator
<input type="submit" id="b1" value="Button1 - Standard" onclick="javascript: alert('button1')">
次のPythonコードは、Firefox上ではなく、IEでCSSロケータxxx
第一を使用して上記のボタンをクリックした:私は、次のHTMLタグを持っているWebページ上のボタンをクリックしようとしています。 Firefoxのオン
:IE8で
from selenium import selenium
s1 = selenium('myhost_ip_address', 4444, '*chrome', 'http://mypage_with_button.com')
print s1.is_element_present('css=input[value="Button1 - Standard"][type="submit"][id="b1"][onclick="javascript: alert(\'button1\')"]')
# Returns True
:
# NOTE: On IE, you might have to click on the notification 'To help protect your security... ActiveX controls that could....' and Allow Blocked Contents if needed
from selenium import selenium
s1 = selenium('myhost_ip_address', 4444, '*chrome', 'http://mypage_with_button.com')
print s1.is_element_present('css=input[value="Button1 - Standard"][type="submit"][id="b1"][onclick="javascript: alert(\'button1\')"]')
# Returns False
私はこのCSSに一意のIDを持っていることを十分に承知していますし、私は私が(onclickの種類などの属性を必要としませんなぜこれが起きているのか不思議です)。
要約すると、この投稿は特にonclick as属性を持つSelenium CSSロケータのためのもので、Firefoxでは動作しますがIEでは動作しません。なぜ誰かがこれがそうだと知っていますか?
FirefoxとIE8は同じHTMLをレンダリングしていますか?たぶん、IE8は奇妙なことをやろうとしているし、マークアップを変更しているかもしれない。両方のブラウザで検査した場合、同じマークアップが表示されますか? –
実際、Firefoxの場合、私はソースをFirebugを使ってはっきりと詳細に見ることができますが、IEは見ることができません。 onclickだけではなく、onchangeや時にはstyle属性も機能しません... CSSでは使えない属性がありますが、Xpathで使うことができます。 – abarik