2017-06-16 10 views
-1

enter image description hereどのようにマウスオーバーすると、電子メニューに移動するには、 "携帯電話のセクション" に

をクリックします。

Actions action = new Actions(driver); 
action.moveToElement(driver.findElement(By.xpath("//*[@id='container']/div/header/div[2]/div/ul/li[1]/a/span[text()='Electronics']"))).build().perform(); 

をモバイルメニューに移動するには:携帯電話上でクリックし

//WebElement mobile = (new WebDriverWait(driver,2)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='container']/div/header/div[2]/div/ul/li[1]/ul/li/ul/li[1]/ul/li[1]/a/span[1][text]()='Mobiles')"))); 

を:

// action.moveToElement(driver.findElement(By.xpath("//*[@id='container']/div/header/div[2]/div/ul/li[1]/ul/li/ul/li[1]/ul/li[1]/a/span[1][text]()='Mobiles')"))).click(); 

WebElement mobile=driver.findElement(By.xpath("html/body/div[1]/div/header/div[2]/div/ul/li[1]/ul/li/ul/li[1]/ul/li[1]/a/span[1][text]()='Mobiles')")); 
mobile.click(); 

は、上記のコードを試みたが、エラーメッセージが表示され動作しませんでした:

//a[@title='Electronics'] 

完全なコードへ:

XPathは、私たちは、モバイル要素に対して、このXPathを使用することができます

+0

マウスのホバーを行う必要がある要素を強調表示するhtml DOMを与えることはできますか? –

+0

こんにちはhttps://www.flipkart.com/アプリケーション – Jagaur

答えて

0

存在しません。マウスを動かす:

Actions action = new Actions(driver); 
action.moveToElement(driver.findElement(By.xpath("//a[@title='Electronics']"))).click().build().perform(); 
//Clicking on the mobile tab 
driver.findElement(by.xpath("//a[@title='Mobiles']")).click(); 

希望します。ありがとう。

+0

こんにちは、これはモバイルページに必要ですこのページを取得する必要がありますhttps://www.flipkart.com/mobiles?otracker=nmenu_sub_Electronics_0_Mobiles Electronic(hover) - >電子シアターの下には「モビール」と呼ばれるオプションがあります – Jagaur

+0

urコードは私を別のページに連れて行きますhttps://www.flipkart.com/mobile-accessories/pr?sid=tyy,4mr&otracker=nmenu_sub_Electronics_0_Mobile%20アクセサリー – Jagaur

+0

はい私はチェックしてからあなただけのURLを送った – Jagaur

関連する問題