Type mismatch: cannot convert from element type Object to Cookie

MorkPork

I've been trying to find a method to download files from websites within Selenium and found a solution here

Trouble is when I copy this example and stick it into eclipse I get an error on one line reading: -

Type mismatch: cannot convert from element type Object to Cookie

The section in question is: -

private BasicCookieStore mimicCookieState(Set seleniumCookieSet) {
        BasicCookieStore mimicWebDriverCookieStore = new BasicCookieStore();
        for (Cookie seleniumCookie : seleniumCookieSet) {    <<---This is the problem line
            BasicClientCookie duplicateCookie = new BasicClientCookie(seleniumCookie.getName(), seleniumCookie.getValue());
            duplicateCookie.setDomain(seleniumCookie.getDomain());
            duplicateCookie.setSecure(seleniumCookie.isSecure());
            duplicateCookie.setExpiryDate(seleniumCookie.getExpiry());
            duplicateCookie.setPath(seleniumCookie.getPath());
            mimicWebDriverCookieStore.addCookie(duplicateCookie);
        }
        return mimicWebDriverCookieStore;
    }

And is called from the section reading: -

LOG.info("Mimic WebDriver cookie state: " + this.mimicWebDriverCookieState);
if (this.mimicWebDriverCookieState) {
    localContext.setAttribute(ClientContext.COOKIE_STORE, mimicCookieState(this.driver.manage().getCookies()));
}

I have no idea how to resolve this issue as I didn't write any of this code and am not that familiar, plus the original posting was well over a year ago so I'm guessing is no longer being monitored/updated.

Can anyone help me at all figuring this one out?

Any help much appreciated.

Rohit Jain

That is because you're using raw type Set as parameter. Change it to Set<Cookie>. For a raw type Set, the iterator you get is just Iterator. And it's next() method will give you element of type Object.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Type mismatch: cannot convert from element type Object to Cookie

From Dev

type mismatch cannot convert from element type object to string

From Dev

Java - Type mismatch: cannot convert from element type Object to String

From Dev

type mismatch cannot convert from element type object to string

From Dev

Java - Type mismatch: cannot convert from element type Object to String

From Dev

Type mismatch: cannot convert from element type Object to List

From Dev

Type mismatch: cannot convert from Object to Class object

From Dev

Type mismatch: cannot convert from Object to Class object

From Dev

Java generics. Type mismatch: cannot convert from object to

From Dev

Type mismatch: cannot convert from Optional<Object> to BasketDTO

From Dev

spark Type mismatch: cannot convert from JavaRDD<Object> to JavaRDD<String>

From Dev

error : Type mismatch: cannot convert from Object to JSONObject

From Dev

Java generics. Type mismatch: cannot convert from object to

From Dev

Type mismatch: cannot convert from Set<Object> to Set<Long>

From Dev

Type mismatch: cannot convert from boolean to int

From Dev

Type mismatch: cannot convert from ListFragment to Fragment

From Dev

Type mismatch: cannot convert from long to int

From Dev

type mismatch: cannot convert from double to Double

From Dev

Type mismatch cannot convert from String to String[]

From Dev

Type mismatch: cannot convert from Scanner to boolean

From Dev

Type mismatch: cannot convert from void to Integer

From Dev

Type mismatch: cannot convert from int to TextView

From Dev

Type mismatch: cannot convert from void to int

From Dev

Type mismatch : cannot convert from double[][] to double[]

From Dev

Type mismatch: cannot convert from boolean to double

From Dev

Type mismatch cannot convert from String to String[]

From Dev

Type mismatch: cannot convert from double to double[]

From Dev

Type mismatch: cannot convert from void to Thread

From Dev

Type mismatch: cannot convert from Element to Elements & first cannot be resolved or is not a field

Related Related

  1. 1

    Type mismatch: cannot convert from element type Object to Cookie

  2. 2

    type mismatch cannot convert from element type object to string

  3. 3

    Java - Type mismatch: cannot convert from element type Object to String

  4. 4

    type mismatch cannot convert from element type object to string

  5. 5

    Java - Type mismatch: cannot convert from element type Object to String

  6. 6

    Type mismatch: cannot convert from element type Object to List

  7. 7

    Type mismatch: cannot convert from Object to Class object

  8. 8

    Type mismatch: cannot convert from Object to Class object

  9. 9

    Java generics. Type mismatch: cannot convert from object to

  10. 10

    Type mismatch: cannot convert from Optional<Object> to BasketDTO

  11. 11

    spark Type mismatch: cannot convert from JavaRDD<Object> to JavaRDD<String>

  12. 12

    error : Type mismatch: cannot convert from Object to JSONObject

  13. 13

    Java generics. Type mismatch: cannot convert from object to

  14. 14

    Type mismatch: cannot convert from Set<Object> to Set<Long>

  15. 15

    Type mismatch: cannot convert from boolean to int

  16. 16

    Type mismatch: cannot convert from ListFragment to Fragment

  17. 17

    Type mismatch: cannot convert from long to int

  18. 18

    type mismatch: cannot convert from double to Double

  19. 19

    Type mismatch cannot convert from String to String[]

  20. 20

    Type mismatch: cannot convert from Scanner to boolean

  21. 21

    Type mismatch: cannot convert from void to Integer

  22. 22

    Type mismatch: cannot convert from int to TextView

  23. 23

    Type mismatch: cannot convert from void to int

  24. 24

    Type mismatch : cannot convert from double[][] to double[]

  25. 25

    Type mismatch: cannot convert from boolean to double

  26. 26

    Type mismatch cannot convert from String to String[]

  27. 27

    Type mismatch: cannot convert from double to double[]

  28. 28

    Type mismatch: cannot convert from void to Thread

  29. 29

    Type mismatch: cannot convert from Element to Elements & first cannot be resolved or is not a field

HotTag

Archive