Migrate to WebDriverBiDi RemoteValue type-safe subclass API#3399
Merged
Migrate to WebDriverBiDi RemoteValue type-safe subclass API#3399
Conversation
Adapt PuppeteerSharp to the new WebDriverBiDi.NET RemoteValue redesign (webdriverbidi-net/webdriverbidi-net#55) which replaces the flat RemoteValue class with a type-safe subclass hierarchy. Key changes: - RemoteValueType is now an enum (was string-based comparisons) - RemoteValue.Value/HasValue/Handle moved to typed subclasses - ArgumentValue replaced by LocalValue - ValueAs<T>() replaced by ConvertTo<T>() / pattern matching - SerializeRemoteValue replaced by native ToLocalValue() - Updated command parameter constructors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…asing Use the published NuGet package instead of a local project reference. Fix RemoteValue.Type ToString to use lowercase for consistency with upstream. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ctReference The migration to the type-safe RemoteValue API incorrectly changed FormatArgumentAsync to call ToLocalValue() for both handle and no-handle cases. For handles, this recursively serializes the value instead of passing it by reference, breaking ExposeFunctionAsync (resolve/reject functions can't be serialized). Use RemoteObjectReference(handle) for the has-handle path, matching the pre-migration ToRemoteReference() behavior. Reverts to local ProjectReference pending a WebDriverBiDi library fix for handle assignment on CollectionRemoteValue types. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- NumberRemoteValue replaces LongRemoteValue/DoubleRemoteValue - GetValueObject handles CollectionRemoteValue and KeyValuePairCollectionRemoteValue which don't extend ValueHoldingRemoteValue in v0.0.49 - Use IObjectReferenceRemoteValue.ToRemoteObjectReference() for passing handles by reference in FormatArgumentAsync Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
850173a to
808f778
Compare
- Use GetValueObject for all RemoteValue items in array deserialization, not just ValueHoldingRemoteValue - Add no-handle fallback for BidiElementHandle in FormatArgumentAsync, matching the existing BidiJSHandle guard Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use GetValueObject consistently for all RemoteValue types in DeserializeRemoteValueDictionary (property and dictionary paths), not just ValueHoldingRemoteValue. Fixes null properties when deserializing objects containing arrays or nested objects. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace remaining ValueHoldingRemoteValue checks with GetValueObject in the deep object deserialization path. Fixes circular object detection and nested array/object deserialization for types that don't extend ValueHoldingRemoteValue in v0.0.49. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- BidiJSHandle.JsonValueAsync: extract values from CollectionRemoteValue and KeyValuePairCollectionRemoteValue, not just ValueHoldingRemoteValue - BidiJSHandle.GetPropertyAsync: for handleless objects (e.g. console log args from BiDi events), look up properties directly from the RemoteValueDictionary instead of round-tripping through the browser Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.0.49 introduced WebDriverBiDiConnectionException (not a subclass of WebDriverBiDiException) for remote disconnections. Catch it in EvaluateAsync and wrap as TargetClosedException to match expected behavior when the browser closes during command execution. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RemoteValueTypeis now an enum replacing string-based comparisons across all BiDi filesRemoteValue.Value/.HasValue/.Handlemoved to typed subclasses (ValueHoldingRemoteValue,IObjectReferenceRemoteValue)ArgumentValue→LocalValue,ValueAs<T>()→ConvertTo<T>()/pattern matchingSerializeRemoteValue(60+ lines) with nativeRemoteValue.ToLocalValue()SetScriptingEnabledCommandParameters,SetCacheBehaviorCommandParameters, andSubscribeCommandParametersconstructorsNotes
Test plan
🤖 Generated with Claude Code