Question: I am using Selenium and I need to upload an image to instagram. But at the time the windows file selector opens I could not get it to search for the image and upload it automatically

[![enter image description here](https://i.stack.imgur.com/HNZuv.png)](https://i.stack.imgur.com/HNZuv.png)

Up to this point my application opens well, when it goes to the point of selecting the file it does not do it automatically

[![enter image description here](https://i.stack.imgur.com/OhzEM.png)](https://i.stack.imgur.com/OhzEM.png)

**I tried using the following codes without success**

```
driver.findElement(By.className(name)).send_keys('C:\\path-to-file\\file.jpg')

```

But it gives me back the value of the second photo, that is, it generates a file selector from the main folder and not the one that I pass through as a parameter

**I am using the following versions:**

```
Java: 8
Selenium: 3.14
ChromeDriver: 76

```

Answer: 
I've been playing around with a solution and posted a Gist to what I have working in terms of programmatically setting content offsets <https://gist.github.com/jfuellert/67e91df63394d7c9b713419ed8e2beb7>
I messed around with several solutions involving a `ScrollView` with one or more `GeometryReaders`, but ultimately I found everything easier if I just ignored `ScrollView` and rolled my own using `View.offset(x:y:)` and a `DragGesture`:

This allows the `LinearGradient` to be panned by either dragging it like a `ScrollView`, or by updating the binding, in the case via a `Slider`

```swift
struct SliderBinding: View {
    @State var position = CGFloat(0.0)
    @State var dragBegin: CGFloat?

    var body: some View {
        VStack {
            Text("\(position)")
            Slider(value: $position, in: 0...400)
            ZStack {
                LinearGradient(gradient: Gradient(colors: [.blue, .red]) , startPoint: .leading, endPoint: .trailing)
                    .frame(width: 800, height: 200)
                    .offset(x: position - 400 / 2)
            }.frame(width:400)
            .gesture(DragGesture()
                        .onChanged { gesture in
                            if (dragBegin == nil) {
                                dragBegin = self.position
                            } else {
                                position = (dragBegin ?? 0) + gesture.translation.width
                            }
                        }
                        .onEnded { _ in
                            dragBegin = nil
                        }
            )
        }
        .frame(width: 400)
    }
}

```

Clamping the drag operation to the size of the scrolled area is omitted for brevity. This code allows horizontal scrolling, use `CGPoint`s instead of `CGSize` to implement it horizontally and vertically.