无法使用selenium 3.3.1在Firefox 50.1.0上运行selenium脚本

时间:2017-04-06 09:27:18

标签: java selenium selenium-firefoxdriver geckodriver

最近我将自动化脚本从selenium 2.53迁移到3.3.1版本,由于以下异常,我们无法在Firefox版本中运行脚本。我正在使用 Firefox 50.1.0 和gecko v0.15.0

Exception in: TS_Testorg.openqa.selenium.SessionNotCreatedException: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds

1 个答案:

答案 0 :(得分:0)

您需要提供firefox二进制位置。一种方法是通过以下代码 -

public class HelpActivity extends Activity {



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.help_page);
}

InputStream iFile = getResources().openRawResource(R.raw.gamehelp);

private String inputStreamToString(InputStream iFile) {
    TextView helpText = (TextView) findViewById(R.id.tvHelpText);
    String strFile = inputStreamToString(iFile);
    helpText.setText(strFile);
    return strFile;
    }

}

此处有更多信息 - http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/