PageObject在CodeceptJS中传入Stepfiles

时间:2019-04-04 09:23:08

标签: gherkin pageobjects codeceptjs

我是CodeceptJS的新手,我需要您的帮助来了解如何将BDD与CodeceptJS一起使用

我们可以在“步骤定义”文件中传递PageObjects吗?

我能够完美地通过它,如下所示:

    public class UnityARHitTestExample : MonoBehaviour
{

    public static UnityARHitTestExample HittestInstance;
    public GameObject[] Allmodels;
    public Transform m_HitTransform;
    public float maxRayDistance = 30.0f;
    public LayerMask collisionLayer = 1 << 10;  //ARKitPlane layer

    bool placed = false;
    public List<DataHandlers> Modelinfo = new List<DataHandlers>();
     List<GameObject> ContainerObject = new List<GameObject>();

    GameObject currentModel;
    string json;
    int indexchoice;
    GameObject temp;
    List<int> indexarray = new List<int>() ;


    float rotateValue = 300f;

    //Original Camera Parent position
    public Transform CameraParent;
    private Vector3 Campos;
    public Text Positions;




    bool HitTestWithResultType (ARPoint point, ARHitTestResultType resultTypes)
    {
        List<ARHitTestResult> hitResults = UnityARSessionNativeInterface.GetARSessionNativeInterface ().HitTest (point, resultTypes);

        if (hitResults.Count > 0 ) {
            foreach (var hitResult in hitResults) {
                if (currentModel != null)
                {
                    Debug.Log("Got hit!");
                   temp = Instantiate(currentModel);
                    ContainerObject.Add(temp);
                    placed = true;

                   temp.transform.position=UnityARMatrixOps.GetPosition(hitResult.worldTransform);
                    temp.transform.rotation=UnityARMatrixOps.GetRotation(hitResult.worldTransform);


                    Debug.Log(string.Format("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z));
                    return true;
                }
            }
        }
        return false;
    }


    private void Start()
    {
        HittestInstance = this;
    }


    private void LateUpdate()
    {


        Camera.main.transform.SetParent(CameraParent.transform);
    }

    private void Update()

    {
        Debug.Log("Changed ");



        #if UNITY_EDITOR   //we will only use this script on the editor side, though there is nothing that would prevent it from working on device
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            //we'll try to hit one of the plane collider gameobjects that were generated by the plugin
            //effectively similar to calling HitTest with ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent
            if (Physics.Raycast(ray, out hit, maxRayDistance, collisionLayer))
            {
                //we're going to get the position from the contact point






                m_HitTransform.position = hit.point;
                Debug.Log(string.Format("x:{0:0.######} y:{1:0.######} z:{2:0.######}", m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z));

                //and the rotation from the transform of the plane collider
                m_HitTransform.rotation = hit.transform.rotation;
            }
        }
#else

        if (Input.touchCount == 1 && m_HitTransform != null && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId) )
        {
            var touch = Input.GetTouch(0);
            //if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved)
            if (touch.phase == TouchPhase.Began && isLocked==false )
            {
                var screenPosition = Camera.main.ScreenToViewportPoint(touch.position);
                ARPoint point = new ARPoint {
                    x = screenPosition.x,
                    y = screenPosition.y
                };

                //User Initial choice was for existing plane & Horizontal plane 
                // prioritize reults types
                ARHitTestResultType[] resultTypes = {
                    ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingGeometry,
                    //ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent, 
                    // if you want to use infinite planes use this:
                   // ARHitTestResultType.ARHitTestResultTypeExistingPlane,
                   // ARHitTestResultType.ARHitTestResultTypeEstimatedHorizontalPlane, 
                    //ARHitTestResultType.ARHitTestResultTypeEstimatedVerticalPlane, 
                    //ARHitTestResultType.ARHitTestResultTypeFeaturePoint
                }; 

                foreach (ARHitTestResultType resultType in resultTypes)
                {
                    if (HitTestWithResultType (point, resultType))
                    {
                        return;
                    }
                }
            }
        }



#endif
    }

但是当我尝试在stepdefinition文件中传递页面Object时它不起作用。

git filter-branch

有人可以举例说明步骤文件,页面对象和特征文件如何相互作用吗?

1 个答案:

答案 0 :(得分:0)

更新:当我使用'require'语句时有效