2016-07-29 6 views
0

以下のコードは、Selenium IDEで作成したセレンスクリプトです。テクノロジーボタンの250ピクセルをクリックして、[教育]タブをクリックするようにしています。アクションクリックスクリプト - Selenium

org.openqa.selenium.WebDriverException: Element is not clickable at point (753.5, 107.51666259765625). Other element would receive the click

2.53.1

package MyPackage; 

import java.util.regex.Pattern; 
import java.awt.Robot; 
import java.awt.event.InputEvent; 
import java.util.concurrent.TimeUnit; 
import org.junit.*; 
import static org.junit.Assert.*; 
import static org.hamcrest.CoreMatchers.*; 
import org.openqa.selenium.*; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.firefox.FirefoxProfile; 
import org.openqa.selenium.firefox.internal.ProfilesIni; 
import org.openqa.selenium.interactions.Actions; 
import org.openqa.selenium.support.ui.Select; 

public class BBC { 
    private String baseUrl; 
    private boolean acceptNextAlert = true; 
    private StringBuffer verificationErrors = new StringBuffer(); 
static ProfilesIni profile = new ProfilesIni(); 
static FirefoxProfile ffprofile = profile.getProfile("selenium"); 
static WebDriver driver = new FirefoxDriver(ffprofile); 

    @Before 
    public void setUp() throws Exception { 
baseUrl = "https://www.google.co.uk/"; 
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 
    } 

    @Test 
    public void testBBCtest2() throws Exception { 
driver.get(baseUrl + "/?gfe_rd=cr&ei=h4qDV93mBOjR8gfVi4qwDg&gws_rd=ssl"); 
driver.findElement(By.id("lst-ib")).clear(); 
driver.findElement(By.id("lst-ib")).sendKeys("BBC news"); 
driver.findElement(By.linkText("Home - BBC News")).click(); 
driver.findElement(By.xpath("//div[@id='site-container']/div/div[2]/ul/li[6]/a/span")).click(); 
WebElement link = driver.findElement(By.xpath("//div[@id='site-container']/div/div[2]/ul/li[6]/a/span")); 
Actions builder = new Actions(driver); 
builder.moveToElement(link, 250, 0).click().build().perform(); 
} 

@After 
    public void tearDown() throws Exception { 
    String verificationErrorString = verificationErrors.toString(); 
    if (!"".equals(verificationErrorString)) { 
    fail(verificationErrorString); 
    } 
} 

private boolean isElementPresent(By by) { 
    try { 
    driver.findElement(by); 
    return true; 
    } catch (NoSuchElementException e) { 
    return false; 
    } 
} 

private boolean isAlertPresent() { 
    try { 
    driver.switchTo().alert(); 
    return true; 
    } catch (NoAlertPresentException e) { 
    return false; 
    } 
    } 

private String closeAlertAndGetItsText() { 
    try { 
    Alert alert = driver.switchTo().alert(); 
    String alertText = alert.getText(); 
    if (acceptNextAlert) { 
    alert.accept(); 
    } else { 
    alert.dismiss(); 
    } 
    return alertText; 
    } finally { 
    acceptNextAlert = true; 
} 
} 
}` 
FireFoxの45.0.0.1 セレンwebdriverを使用:あなたは「教育」タブは、そのは、マウスオーバーが、コンソールにはエラーを与えるかのように強調表示されているスクリプトを実行することで見ることができます
+0

実際に何をしたいですか?私たちの質問は明確ではありません。明確に説明してください... –

+0

教育用ボタンはテクノロジーボタンの右側に250ピクセルで、ウェブサイトはパブリックウェブサイトですこれを自分で試してみてください。 –

答えて

0

の代わりに:

builder.moveToElement(link, 250, 0).click().build().perform(); 

試してみてください。

builder.moveToElement(link, 250, 0); 
builder.clickAndHold(); 
builder.release(); 
builder.build(); 
builder.perform(); 
+0

これで運がいいわけではありませんが、テストはパスしていますが、その外観で何かをクリックしようとしていません。 –