We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In case of Collection of Qurey fields ex.
List links = IntStream.range(1, 6) .mapToObj(i -> new Query().defaultLocator(By.cssSelector("table > tbody > tr:nth-child(" + i + ") a"))) .collect(Collectors.toList());
the initQueryObjects method unable to set Driver object.
In this case we can change initQueryObjects method```
private static void initQueryObject(Object object, Field field, RemoteWebDriver driver) { try { field.setAccessible(true); Query queryObject = (Query) field.get(object); if (null != queryObject) { queryObject.usingDriver(driver); } } catch (IllegalAccessException e) { throw new RuntimeException(e); } } private static void initQueryCollection(Object object, Field field, RemoteWebDriver driver) { try { field.setAccessible(true); @SuppressWarnings("unchecked") Collection<?> unsafeCollection = (Collection) field.get(object); unsafeCollection .stream() // making this collection safe .filter(Query.class::isInstance) .map(Query.class::cast) .filter(Objects::nonNull) .forEach(query -> query.usingDriver(driver)); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } public static void initQueryObjects(Object object, RemoteWebDriver driver) { Arrays.stream(object.getClass().getDeclaredFields()) .forEach( field -> { if (field.getType() == Query.class) { initQueryObject(object, field, driver); } else if (Collection.class.isAssignableFrom(field.getType())) { initQueryCollection(object, field, driver); } } ); }
private static void initQueryObject(Object object, Field field, RemoteWebDriver driver) { try { field.setAccessible(true); Query queryObject = (Query) field.get(object); if (null != queryObject) { queryObject.usingDriver(driver); } } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
private static void initQueryCollection(Object object, Field field, RemoteWebDriver driver) { try { field.setAccessible(true); @SuppressWarnings("unchecked") Collection<?> unsafeCollection = (Collection) field.get(object); unsafeCollection .stream() // making this collection safe .filter(Query.class::isInstance) .map(Query.class::cast) .filter(Objects::nonNull) .forEach(query -> query.usingDriver(driver)); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } public static void initQueryObjects(Object object, RemoteWebDriver driver) { Arrays.stream(object.getClass().getDeclaredFields()) .forEach( field -> { if (field.getType() == Query.class) { initQueryObject(object, field, driver); } else if (Collection.class.isAssignableFrom(field.getType())) { initQueryCollection(object, field, driver); } } ); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In case of Collection of Qurey fields ex.
the initQueryObjects method unable to set Driver object.
In this case we can change initQueryObjects method```
The text was updated successfully, but these errors were encountered: