Selector using Multiple Quotation Marks in CSS

Struggling to find a unique identifier for a password field? I'm experimenting with attributes and quotations, trying to figure out how to handle multiple sets. Is it necessary to mix single and double quotes when dealing with three sets?

(Could a different approach, like using descendants/children in a path-like manner, be more effective?)

The website I'm currently working on can be found here.

This is the code snippet I've worked on so far:

import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# create driver object and launch the webpage
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 20)
driver.get("https://myibd.investors.com/secure/signin.aspx?eurl=https://marketsmith.investors.com/")

# switch to the iframe we need
driver.switch_to.frame(driver.find_element_by_css_selector("iframe[id = 'signin-iframe']"))

# variable for username field
username_field = driver.find_element_by_css_selector("input[name='username'][data-gigya-placeholder='Email']")
# variable for password field
password_field = driver.find_element_by_css_selector()

I want to experiment with these two tags & values:

gigya-expression:data-gigya-placeholder="screenset.translations['PASSWORD_132128826476804690_PLACEHOLDER']"
gigya-expression:aria-label="screenset.translations['PASSWORD_132128826476804690_PLACEHOLDER']"

Edit 1
Tried new methods that didn't work:
1.) Attempted to escape quotes within the value using backslashes as suggested below.

password_field = driver.find_element_by_css_selector("input[gigya-expression:data-gigya-placeholder='\"screenset.translations[\'PASSWORD_132128826476804690_PLACEHOLDER\']\"']")

2.) Explored using escape characters for single and double quotes, as discussed in this article.

password_field = driver.find_element_by_css_selector("input[gigya-expression:data-gigya-placeholder='"screenset.translations['PASSWORD_132128826476804690_PLACEHOLDER']"']")

Edit 2
Using XPath as a workaround
Although CSS posed challenges, xpath provided a solution. Inspecting the target element and copying the XPath by right-clicking on the HTML was helpful.

Copied XPath:

//*[@id="gigya-login-form"]/div[2]/div[3]/div[2]/input

Python code implementation:

password_field = driver.find_element_by_xpath("//*[@id='gigya-login-form']/div[2]/div[3]/div[2]/input")

Answer №1

If you're struggling with quotations, keep in mind that you can use the escape character \ to handle any special characters within a line of code.

For instance, if I set

str="\"\"\"\""
, then running print(str) will display """".


Both of these examples are valid strings too, because the single quotes are enclosed by double quotation marks.

gigya-expression:data-gigya-placeholder="screenset.translations['PASSWORD_132128826476804690_PLACEHOLDER']" 
gigya-expression:aria-label="screenset.translations['PASSWORD_132128826476804690_PLACEHOLDER']"

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

Deactivate the Shockwave Flash plugin by utilizing Selenium and Python programming

Having issues with the Shockwave Flash plugin crashing during a crawling project. Is there an easy method to disable it from the start? Your assistance is greatly appreciated! ...

Navigating in a Curved Path using Webkit Transition

Currently, I am working on a simple project to learn and then incorporate it into a larger project. I have a basic box that I want to move from one position to another using CSS webkit animations and the translate function for iOS hardware acceleration. I ...

"Adjusting the size of a circle to zero in a D3 SVG using Angular 2

Trying to create a basic line graph using d3 in Angular 2 typescript. Below is the code snippet: import { Component, ViewChild, ElementRef, Input, OnInit } from '@angular/core'; import * as d3 from 'd3'; @Component({ selector: 'm ...

Guide to importing a single icon from an icon library image

I'm not very experienced with web front-end development. The web designer provided me with a JPG file that contains a bar full of icons. https://i.sstatic.net/3fmAx.png However, I need to use these icons individually. I'm unsure if there is a ...

Challenges of positioning two div elements next to each other without adhering to the width of the container

Apologies for my limited knowledge of CSS and HTML; I am relatively new to this. I have gone through various questions and tutorials on how to align two divs side by side, but I seem to be facing difficulties in controlling the width of the divs in my cod ...

An assessment consisting of three parts, with the initial section required to match the size of the browser window using jQuery and Javascript

UPDATE: The issue was resolved by adding the Doctype at the top of the page - "<!DOCTYPE html>" (no spaces between tags < , > and other characters) I am experimenting with a webpage that contains four sections. The first section should take up ...

Image compression using JavaScript or JSP

As I work on creating a website similar to flickr or 500px, I've encountered an issue with the loading time of my photo-filled page. Despite resizing the images using CSS, the loading time is excessively long, taking up to 2 minutes for the page to fu ...

Leveraging highchart SVG graphics in Selenium testing applications

Looking for some assistance with running a Selenium test in Java involving SVG high chart images on a webpage. The challenge I am facing is getting Selenium to recognize each element on the high chart and clicking on them to trigger another event. Below i ...

How to access a sibling file within a module in Python3

the structure of my python project looks like this: ├── main.py └── util ├── color.py ├── __init__.py └── student.py main.py contains the following code: from util.student import fun fun("calling fun from main") ...

Error: ChromeDriver Does Not Support Current Chrome Version (SessionNotCreatedException) - The session could not be created as the current version

An exception occurred with no changes made to the WebDriver version or project: ChromeDriver was started successfully. [main] 01:29.743 FAILED Open error : (SessionNotCreatedException) session not created: This version of ChromeDriver only supports Chro ...

Strategizing the Management of Multiple Selenium Sessions for Web Scraping

I've been developing a Python web scraping program using the Selenium package. The program is set up as a web service on a virtual machine, allowing users to access it from their own computers for web scraping purposes. While I'm still working o ...

Input various colored text within an HTML element attribute

In my asp.net project, I am looking to dynamically change the text color of a table cell based on a certain parameter. Here's an example scenario: TableCell dataCell = new TableCell(); foreach (var o in results) { ...

options for adaptive web layout

My goal is to ensure my website is responsive by utilizing HTML5, CSS3, JavaScript, and jQuery. I am facing an issue with the responsiveness of my menu in the CSS code. PRÉSENTATION OFFRES PRODUITS RÉFÉRENCE CONTACT Menu nav { ...

Prevent the box from closing automatically after submitting a form using jQuery

Despite my efforts to keep a simple dialog box open after submitting a form, it continues to close. I tried using the preventDefault method in jQuery, but it didn't solve the issue. Below is the code snippet: $(document).ready(function(e) { $(&apo ...

Maximized vertical and horizontal dimensions

I'm struggling to achieve a split background on my site with two colors vertically, fullscreen in both height and width. Can anyone spot what I might be doing wrong here? Any help is much appreciated. Thank you. You can view the test page here. HTML ...

The grid is experiencing improper sizing in the row orientation

Challenges with Grid Layout In my current project, I am facing a challenge in creating a responsive layout with a dynamic grid within a page structure that includes a header and footer. The main issue arises when the grid items, designed to resemble books ...

What is causing concatenated string class names to fail in Tailwind CSS?

Whenever I find myself needing to style my React elements, I end up using the style attribute instead of className. None of the examples I've come across seem to apply styles that fit my specific needs. Can you shed some light on why this happens and ...

Upgrade your input button style using jQuery to swap background images

I have an input button with an initial background image. When a certain condition changes, I want to update its image using jQuery without overriding the button's global CSS in the stylesheet. Is there a way to only change the background attribute wit ...

Achieving vertical and horizontal centering of content using tailwind.css in React with Next.js

Struggling to align an svg component at the center of a parent div element both vertically and horizontally using tailwind.css in a React project. Seeking feedback on my code below to identify any mistakes. The current issue, as shown in the included png ...

What could be the reason for the script's output displaying a list of None values?

I'm puzzled by a simple issue - why is my code printing None? When I run the code directly in my terminal, it simply outputs None. However, if I execute the same code from a file or through an online Python compiler, the output differs. When coding i ...