Guide on filling in credentials in Facebook popup using Webdriver with Javascript

On my website, I have a feature where users can authenticate using Facebook. Currently, my site is not public, but you can see a similar process in action at agar.io. Just click on "Login and play" and then click on "Sign in with Facebook". This will open a popup window.

I am able to control the main page easily with Webdriver, but I'm struggling to figure out how to access this popup window using JavaScript. My code looks like this:

var browser = new webdriver.Builder().usingServer().withCapabilities({
'browserName': 'chrome'

}).build();

After initializing the browser object, I can navigate through my site. The challenge now is figuring out how to switch focus from the main page to this popup window so that I can input the user's login credentials.

Answer №1

If you encounter a popup, don't worry about it too much. The following pseudocode outlines the solution in handling it efficiently:

Click on element using XPath: //button[text()='Login and play']
Click on element using XPath: //button[span/text()='Sign in with Facebook']
Wait for CSS path to be present: #facebook body
<Fill out any additional forms as needed>
Click on element using XPath: //button[text()='Play Now']

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

jQuery AJAX call failing to return to page

Currently, my form is set up to upload multiple text fields and a file to a PHP script for saving. The script successfully saves the file and text fields to an SQL database. At the end of the PHP script, I have the following code snippet: ('state&apo ...

Ways to determine the count of inactive browsers associated with a node in Selenium Grid2

Currently, I have a setup consisting of 5 nodes, each with 10 Firefox browsers connected to a hub. The issue I am facing is that I am running out of available Firefox browsers on each node. This means any new Selenium runs are being queued up at the Hub a ...

Sending a user to an external website through an XML response

In my current project, I am utilizing jQuery to fetch a PHP file. The PHP file executes a cURL request to an external website in order to obtain information for a payment request. The external site responds with XML data structured as follows: <Request ...

Creating a mouseover popup window for a specific text citation based on its ID using JavaScript in XSLT

I have implemented the following XML code for citations related to figures, tables, and reference citations. When hovering over the citation, it should display the relevant text based on the id and href. XML code for Citation: Fig. <link href="#ecog34 ...

What is the best way to add an element from a parent component to an array within a child component in a Vue 3 application?

I am in the process of transitioning from Vue's Options API to the Composition API, and as part of this transition, I have built a small Todo App. Within App.vue, my code looks like this: <template> <div id="app"> <div ...

Peculiar redirection encountered while handling a form with checkbox option

When I try to submit the form in Chrome, the PHP file does not get called and I am redirected to another HTML page. However, in Firefox, when I select three checkboxes, it redirects me to that same HTML page as in Chrome. I even tried using radio buttons i ...

Display a dynamic list of data fetched from an axios Get request in a React MUI dropdown menu

import { useEffect, useState } from "react"; import Box from "@mui/material/Box"; import FormControl from "@mui/material/FormControl"; import InputLabel from "@mui/material/InputLabel"; import MenuItem from "@m ...

Instructions on how to extract a specific timestamp from a video and utilize it to initiate an event

Is there a way to trigger an event or animation at a specific time in a video or frame of the video? For instance, I want text to appear when a video reaches 30 seconds. I've experimented with currentTime, tried using loadeddata, and attempted to u ...

Express.js refuses to serve static assets

I've been struggling to set up my express server to serve static files, but no matter what I try, I can't seem to get it working. I've attempted various solutions without success. Here is my folder structure: App - Web -- public --- images ...

Utilize JavaScript to send login information to a website

I have a specific task in mind: creating a script that will automatically fill in certain data on an HTML website. To illustrate, let's imagine the site is the StackOverflow login page and I want to input my username and password. For the username fi ...

An existing INPUT value can be modified by dynamically adding or subtracting values from SELECT OPTION

I currently have an <input readonly> field that displays the total_price value retrieved from a shopping cart stored in the database table. Moreover, I have included a <select> element with different transport options that can either increase o ...

Selenium-WebDriver UnhandledPromiseRejectionWarning Issue

I'm a newcomer to the world of Selenium web driver and I've encountered an issue while trying to 'get' a web address. Here's the snippet of code causing trouble: const {Builder, By, Key, until} = require('selenium-webdriver&a ...

Exploring the use of jQuery autocomplete to retrieve data attributes

Looking to retrieve additional data-attributes from the Mapbox API. The autocomplete plugin I implemented can be found here. (Utilizing Python/Django for backend) My goal is to send extra information such as country code, city, and country to my databas ...

What is the best way to retrieve data attributes from multiple div elements that share the same class name?

I have multiple div elements with the same class name. I want to extract the data attribute from these div's. I have tried some code and managed to get the result. However, I am unsure if this is the best approach for retrieving data("cartid"). Any as ...

React Router v6 is throwing an error stating that within the <Routes> component, all children must be either a <Route> or <React.Fragment>

While the code snippet below may have worked perfectly fine in React Router v5, it's causing an error in React Router v6. Error: [Player] is not a <Route> component. All component children of <Routes> must be a <Route> or <React ...

Which one should I prioritize learning first - AngularJS or Laravel?

As a novice web developer, I am embarking on my first journey into the world of frameworks. After much consideration, I have narrowed it down to two options: AngularJS and Laravel. Can you offer any advice on which one would be best for me to start with? ...

Using Jquery to duplicate a row from one table and insert it into another table

Recently, I've dived into the world of jQuery and JavaScript with the goal of creating a simple app. The main functionality I'm trying to implement is the ability to copy a row from one table to another and then delete the original row when a but ...

Center a span vertically inside a div as the text within the span grows to occupy the entire div

I am facing an issue with a table that has 25 td's. Each td contains specific elements as shown below: <td> <div> <span> text </span> </div> </td> Additionally, there is a script in place that adj ...

What steps can I take to prevent Internet Explorer from caching my webpage?

After implementing Spring MVC for Angular JS on the front end, I encountered an issue where logging in with different user credentials resulted in incorrect details being displayed. This problem only occurred in Internet Explorer, requiring me to manually ...

A guide on changing the size of the browser window in Chrome and Firefox using Selenium in Python

We have developed browser extensions for Chrome, Firefox, and Safari and are looking to conduct Selenium tests on them. Currently, we are running the tests on an Ubuntu server with Firefox and Chrome installed (along with ChromeDriver). While the tests wor ...