2017-06-06 4 views
-2

Actions action = new Actions(driver); IWebElement we = driver.FindElement(By.XPath(".//*[@class='ms-crm-CommandBar-Button ms-crm-Menu-Label']"));
action.MoveToElement(driver.FindElement(By.XPath(".//*[@class='ms-crm-CommandBar-Button ms-crm-Menu-Label-Hovered']"))).Click().Build().Perform();
このコードでこの要素をクリックできないのはなぜですか?

以下のように要素を期待する:このクラス"ms-crm-CommandBar-Button ms-crm-Menu-Label"が時にマウスオーバー"ms-crm-CommandBar-Button ms-crm-Menu-Label-Hovered"ようになっていること

< span tabindex = "-1" class="ms-crm-CommandBar-Button ms-crm-Menu-Label" style="max-width: 200px;"> <a tabindex = "0" class="ms-crm-Menu-Label" onclick="return false"> <img tabindex = "-1" class="ms-crm-ImageStrip-New_16 ms-crm-commandbar-image16by16" style="vertical-align: top;" src="/_imgs/imagestrips/transparent_spacer.gif"> <span tabindex = "-1" class="ms-crm-CommandBar-Menu" [enter image description here][1]style="max-width: 150px;" command="lead|NoRelationship|HomePageGrid|Mscrm.NewRecordFromGrid"> New </span> <div class="ms-crm-div-NotVisible"> Create a new Lead record. </div>
</a> </span>

注意。

多くのありがとうございます。

+0

コピーアンドペーストの間違い。実際には、 "。" // –

+0

こんにちは - ようこそ、前に "質問する方法"をお読みください:https://stackoverflow.com/help/how-to-ask – Cadburry

答えて

0

ホバリングされた要素を検索するとき、それは存在しません。 最初に要素をホバーする必要があります。次に、ホバーされた要素を見つけてクリックすることができます。 action.MoveToElement(driver.FindElement(By.XPath("//*[@class='ms-crm-CommandBar-Button ms-crm-Menu-Label']"))).Build().Perform().MoveToElement(driver.FindElement(By.XPath("//*[@class='ms-crm-CommandBar-Button ms-crm-Menu-Label-Hovered']"))).Click().Build().Perform();

+0

結果メッセージ:\t テストメソッドUnitTestProject1.CRMTest.CRM_Test_in_IE例外をスロー: OpenQA.Selenium.NoSuchElementException:xpath == // * [@ class = 'ms-crm-CommandBar-Button ms-crm-Menu]で要素を見つけることができません-Label '] –

+0

以下のコードを試してみましたが、アイコン(lable + New)のハイライトが見えますが、Clickはまったく動作しません。アクションアクション=新しいアクション(ドライバ); MoveToElement(driver.FindElement(By.XPath( "// img)"); MoveToElement(driver.FindElement(By.XPath( "// msgm-Menu-Label") ")) )()をクリックします。ビルド()。();を実行します。 –

+0

このコードは動作します...最終的に。ありがとうございました。アクションアクション=新しいアクション(ドライバ); ();)をクリックします。ビルド()。();を実行します。 driver.FindElement(By.XPath( "// * [@ class = 'ms-crm-CommandBar-Button ms-crm-Menu-Label-Hovered']"))をクリックします。 –

0

最初のホバーケースでは、その要素をクリックするとその要素に移動する必要があります。

Actions actions = new Actions(driver); 
action.moveToElement(mainMenu).moveToElement(driver.findElement(By.xpath("ur element"))).click().build().perform(); 
+0

アクションaction = newアクション(ドライバ); ();))。)Build()。Perform()メソッドを呼び出すと、 ; action.MoveToElement(driver.FindElement(By.XPath( "// * @ class = 'ms-crm-CommandBar-Button ms-crm-Menu-Label-Hovered']」)))をクリックします。 ().Perform();結果のメッセージ:テストメソッドUnitTestProject1.CRMTest.CRM_Test_in_IE例外がスローされました:OpenQA.Selenium.NoSuchElementException:xpathで要素を見つけることができません== // * [@ class = 'ms-crm-CommandBar-Button ms-crm-Menu-ラベル]] –

+0

このコードは動作します...最終的に。ありがとうございました。アクションアクション=新しいアクション(ドライバ); ()。()。ビルド()。P erform();をクリックします。 ();))。)をクリックします。[OK]をクリックして、[次へ]をクリックします。 –

関連する問題