1
我正在使用Selenium Webdriver(Java),我想使用IE驅動程序進行測試,但是我想出了問題,任何人都可以幫我解決這個問題,在Firefox中運行正常的腳本無法在IE中運行,我只是打開一個谷歌頁面並搜索一些詞,但我的代碼只打開谷歌頁面編寫關鍵字,但無法使用IEdriver在谷歌頁面上點擊serch按鈕,之後也很多谷歌我發現一個thimg,當IE瀏覽器打開它將在IE8兼容性視圖中打開,並由於此屬性像id,名稱相比,FF改變,但當我改變這個IE8視圖手動屬性是相同的FF,(按鍵盤上的F12鍵打開IE上的開發者工具)那麼任何人都可以請讓我知道如何克服這個問題或者如何在IE8模式下打開IE瀏覽器,或者任何人都知道使用IE瀏覽器的任何不同解決方案enium webdriver。 我的代碼如下在FF中運行正常的腳本無法在IE中運行
package backOffice;
import java.io.File;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName;
import bsh.ParseException;
public class Time
{
private WebDriver driver;
private String baseUrl= "http://www.google.co.in/";
public static void main(String args[]) throws InterruptedException
{
Time tm=new Time();
tm.trial();
}
private void trial() throws InterruptedException
{
File file = new File("C:/Documents and Settings/Administrator/Desktop/32- bit_IEDriverServer_Win32_2.31.0/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability("ignoreZoomSetting", true);
driver=new InternetExplorerDriver(caps);
driver.get(baseUrl + "/");
driver.findElement(By.id("gbqfq")).clear();
driver.findElement(By.id("gbqfq")).sendKeys("harshal kakade");
driver.findElement(By.id("gbqfb")).click();
driver.findElement(By.linkText("Harshal Kakade - India | LinkedIn")).click();
}
}
感謝,
Harshal。
也許這可以幫助: http://stackoverflow.com/questions/5804714/selenium-ie8-force-ie8-compatibility-view – SpaceCowboy
你真的應該試試這個反對的東西,是不是谷歌。 Google的標記非常複雜,例如,我使用的是完全不同的ID。 – Arran
嗨艾蘭, 我試過與其他網絡也是我觀察到的行爲。 謝謝, Harshal。 –