http://www.walmart.com/browse/TV-Video/TVs/_/N-96v3のようなページから製品の在庫状況のテキストを取得する方法を見つけようとしています。 (ストアが選択されたら) 郵便番号として 76574 を選択し、[ストア内] タブに移動しました
私が今持っているコードは
WebElement hoverElement = driver.findElement(By.xpath(".//*[@id='Body_15992428']/span"));
WebElement hidden = driver.findElement(By.xpath(".//*[@id='slapInfo_NoVariant_15992428']/div"));
Actions builder = new Actions(driver);
builder.clickAndHold(hoverElement).build().perform();
System.out.println(hidden.getText());
**編集: 試しprofile.setEnableNativeEvents(false);
てみたところ、自動ブラウザ ウィンドウにテキストが表示されるようになりました。私はまだ欲しいテキストに到達できません。例外はスローされず、ドライバーがまだ非表示であると見なされるため、何も表示されません。誰でもこれを修正する方法を知っていますか?
私は得続けます
Exception in thread "main" org.openqa.selenium.InvalidElementStateException: Cannot perform native interaction: Could not load native events component.
やった後も
profile.setEnableNativeEvents(true);
非表示のテキストを取得できる他の方法はありますか、またはここで何が間違っていますか?
さらに、firebug でコードを検査しているときに、このコードがあることがわかりました
<script type="text/javascript"> WALMART.$(document).ready(function(){ WALMART.$('#Body_15992428').hover(function(){ WALMART.$('#SeeStoreAvailBubble').wmBubble('update',WALMART.$('#bubbleMsgUpdate_15992428').html()); }); }); </script>
javascript を直接使用する方法はよくわかりませんが、javascript executor を使用してメッセージ テキストを直接取得する方法はありますか?