Expect two elements to be equal

Cyberdelphos

I want to test if two elements in two different pages are equal. The reason for this is that I need to check a "copy" function that already works in my page, so both elements (divs in this case) have to be indentical:

I found that there's a method in protractor for element objects called "clone" but doesn't explains its purpose that much. Anyway I tried this:

// In the first page:
browser.get("/page1");
var clone1 = element(by.id("firstElem")).clone();

// then navigating to the other page
browser.get("/page2");
var clone2 = element(by.id("secondElem")).clone();

// then the expectation of them to be equal
expect(clone1).toEqual(clone2);

but the expectation fails with a very heavy stacktrace. Also tried comparing:

expect(clone1 == clone2).toBeTruthy();

which fails again.

  • What is "clone()" supposed to be used for? and,

  • How do I compare two divs in two separate pages for being identical?

alecxe

What is "clone()" supposed to be used for?

I've recently created a closely related question, you can follow the updates there:

How do I compare two divs in two separate pages for being identical?

Depending on your end goal, you may compare "outer HTML" representations of the elements using getOuterHtml() , example:

browser.get("/page1");
element(by.id("firstElem")).getOuterHtml().then(function(value) {
    browser.get("/page2");
    expect(element(by.id("secondElem")).getOuterHtml()).toEqual(value);
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to compare two JSON objects with the same elements in a different order equal?

From Dev

How to associate two equal child elements?

From Dev

Compare two lists to make them equal in elements

From Dev

divide and conquer - find median between two arrays of equal size that contain unique elements?

From Dev

Checking if two elements are equal in JavaScript

From Dev

rspec expect date to equal

From Dev

check how many elements are equal in two numpy arrays python

From Dev

How to give equal space to two elements?

From Dev

css flexbox : equal space between elements except the first two of ul>li*7 list

From Dev

Expect two elements to be equal

From Dev

Creating a Stream based on if both ordered elements are equal in two other streams

From Dev

How to find the set of indices where two vectors have equal elements in Python

From Dev

Chai expect to be one of array elements

From Dev

Given a set N of integers and an integer y, determine if there two elements exist in N whose absolute difference is equal to y

From Dev

Two lists with same elements are not equal. Why?

From Dev

What exception to throw when two values I expect to be equal are not equal? (C#)

From Dev

finding the sum of two arrays elements that is equal to the input

From Dev

Compare two lists to make them equal in elements

From Dev

Change the order of two equal elements in an STL multiset

From Dev

Count number of times two elements in array are less than or equal to a sum value - Javascript

From Dev

Given two vectors, get a matrix of boolean values indicating where elements of vectors are equal

From Dev

Define true or false if in array two equal elements are present

From Dev

with complexity better than quadratic, how to find if there is two elements in an array there sum equal a passed value

From Dev

Compare two array and return an array to show which elements are equal or not

From Dev

Checking if two IDs of two elements with the same class are equal

From Dev

Equal elements and Tree set

From Dev

Two Set contain same elements but they are not equal. Why that result?

From Dev

How to find if two or more continuously elements of a vector are equal in R

From Dev

Relate indices where two dataframes are equal with elements in another array

Related Related

  1. 1

    How to compare two JSON objects with the same elements in a different order equal?

  2. 2

    How to associate two equal child elements?

  3. 3

    Compare two lists to make them equal in elements

  4. 4

    divide and conquer - find median between two arrays of equal size that contain unique elements?

  5. 5

    Checking if two elements are equal in JavaScript

  6. 6

    rspec expect date to equal

  7. 7

    check how many elements are equal in two numpy arrays python

  8. 8

    How to give equal space to two elements?

  9. 9

    css flexbox : equal space between elements except the first two of ul>li*7 list

  10. 10

    Expect two elements to be equal

  11. 11

    Creating a Stream based on if both ordered elements are equal in two other streams

  12. 12

    How to find the set of indices where two vectors have equal elements in Python

  13. 13

    Chai expect to be one of array elements

  14. 14

    Given a set N of integers and an integer y, determine if there two elements exist in N whose absolute difference is equal to y

  15. 15

    Two lists with same elements are not equal. Why?

  16. 16

    What exception to throw when two values I expect to be equal are not equal? (C#)

  17. 17

    finding the sum of two arrays elements that is equal to the input

  18. 18

    Compare two lists to make them equal in elements

  19. 19

    Change the order of two equal elements in an STL multiset

  20. 20

    Count number of times two elements in array are less than or equal to a sum value - Javascript

  21. 21

    Given two vectors, get a matrix of boolean values indicating where elements of vectors are equal

  22. 22

    Define true or false if in array two equal elements are present

  23. 23

    with complexity better than quadratic, how to find if there is two elements in an array there sum equal a passed value

  24. 24

    Compare two array and return an array to show which elements are equal or not

  25. 25

    Checking if two IDs of two elements with the same class are equal

  26. 26

    Equal elements and Tree set

  27. 27

    Two Set contain same elements but they are not equal. Why that result?

  28. 28

    How to find if two or more continuously elements of a vector are equal in R

  29. 29

    Relate indices where two dataframes are equal with elements in another array

HotTag

Archive