Behat在docker环境中使用selen进行测试

时间:2018-01-23 09:49:06

标签: selenium docker selenium-webdriver docker-compose behat

嘿,我有一个2个容器: drupalfront 浏览器。 drupalfront容器有behat测试,并尝试在http://browser:4444/wd/hub

联系selenium浏览器

然而,这回复

  **┌─ @BeforeScenario # FeatureContext::resizeWindow()
  │
  ╳  Could not open connection: Unable to create new service: XpiDriverService
  ╳  Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'**

这是behat的正确配置吗?

1 个答案:

答案 0 :(得分:3)

默认情况下,Behat会查找硒:http://localhost:4444/wd/hub

如果您在另一台计算机或其他端口上启动selenium服务器,则需要使用wd_host selenium2behat.yml下的wd_host: 'http://192.168.1.2:4444/wd/hub' 指定此内容。

示例:

wd_host: 'localhost:4445/wd/hub'

或者如果在具有不同端口的本地计算机上:

    private ListView mListView;
    private DatabaseReference mDatabse;
    private ArrayList<String> arrayList = new ArrayList<>();
    private ArrayAdapter<String> adapter;
    String Date;
    Calendar calendar;
    SimpleDateFormat simpleDateFormat;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_account);
        mListView = (ListView) findViewById(R.id.database_list_view);
        calendar = Calendar.getInstance();
        simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
        Date = simpleDateFormat.format(calendar.getTime());

        FirebaseUser currentFirebaseUser = FirebaseAuth.getInstance().getCurrentUser() ;
        mDatabse = FirebaseDatabase.getInstance().getReference().child("CheckInOut").child(currentFirebaseUser.getUid()).child(Date).child("userCheckIn");

        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, arrayList);

        mListView.setAdapter(adapter);

        mDatabse.addChildEventListener(new ChildEventListener() {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                String string = dataSnapshot.getValue(String.class);
                arrayList.add(string);
                adapter.notifyDataSetChanged();
            }

            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {

            }

            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {

            }

            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {

            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });

    }
  

确保为浏览器使用正确的驱动程序。