Authenticate to the target service and create a browser context with the required cookies and session data.
import Anchorbrowser from "anchorbrowser";(async () => { const anchorClient = new Anchorbrowser() const session = await anchorClient.sessions.create({ browser: { profile: { name: 'new-profile', persist: true } } }) const sessionId = session.data.id; // Navigate to the login page await anchorClient.sessions.goto(sessionId, { url: 'https://example.com/login' }) // Fill in your login credentials await anchorClient.sessions.mouse.click(sessionId, { x: 100, y: 200 }) await anchorClient.sessions.keyboard.type(sessionId, { text: 'your-username' }) await anchorClient.sessions.mouse.click(sessionId, { x: 100, y: 250 }) await anchorClient.sessions.keyboard.type(sessionId, { text: 'your-password' }) // Submit the login form await anchorClient.sessions.mouse.click(sessionId, { x: 100, y: 300 }) console.log('Authentication completed. Profile will be saved when session ends.')})();
3
Save Profile
End the session. The profile will be automatically saved since you set persist: true when creating the session.
import Anchorbrowser from "anchorbrowser";(async () => { const anchorClient = new Anchorbrowser() // After completing authentication, end the session to save the profile await anchorClient.sessions.delete(sessionId) console.log('Session ended. Profile "new-profile" has been saved.')})();
4
Use the profile in other sessions
Now, when creating a new session pass the profile parameter with the name of the profile you created to load the saved browser context.