How click checkbox with CSS locator ::after using playwright
I have to click checkbox for term & conditions. I have used .click()
and .check
in my code. But when I am running the code, it's clicking on the terms & conditions and it's redirecting to another page. can you suggest any help.
below is my html
When I hover mouse to ::before
and ::after
checkbox is highlighting.
await this.page.locator('#lb-confirm').click()
await this.page.locator('#lb-confirm').check
do you know?
how many words do you know
See also questions close to this topic
-
how to change prettier format for react native
my code formatting prettier didn't works well for react native, i don't understand where to config it but it works well with flutter
from this code
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( <View> <Text>Apps</Text> </View> ) }
it's formatted to this
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( < View > < Text > Apps < /Text> < /View> ) }
-
MarkLogic server-side JavaScript and XQuery
I am just starting using NoSQL MarkLogic DB and trying to choose for me the best query language to learn and use in future. On server side MarkLogic provides the possibility to use JavaScript API or XQuery API.
I want to receive an advice. Which language is better to concentrate on and learn? JavaScript or XQuery?
- Popover in chrome extension using js
-
Output the Tuesday 6 weeks in the future in Python?
UPDATE: post edited to add answer to end of post
Core Question
Using Python, how do I output the date of the Tuesday that occurs 6 weeks after a certain date range?
Context
I work at a SaaS company in a customer facing role. Whenever I do an implementation for a client, the client receives a survey email on the Tuesday that occurs in the 6th week after our initial interaction.
To know which Tuesday to be extra nice on, we currently have to reference a chart that says if the interaction falls in date range x, then the client receives their survey solicitation on Tuesday y.
An example of this would be: if the interaction happened sometime within Apr. 18 - Apr. 22, then the survey goes out on May 31.
I would prefer for this to be done without having to hard code the date ranges and their corresponding Tuesdays into my program (just because I'm lazy and don't want to update the dates manually as the months go by), but I'm open to that solution if that's how it has to be. :)
Code Attempt
I can use datetime to output a particular date x weeks from today's date, but I'm not sure how to get from here to what I want to do.
import time from datetime import datetime, timedelta time1 = (time.strftime("%m/%d/%Y")) #current date time2 = ((datetime.now() + timedelta(weeks=6)).strftime('%m/%d/%Y')) #current date + six weeks print(time1) print((datetime.now() + timedelta(weeks=6)).strftime('%m/%d/%Y'))
Disclaimer: I am a beginner and although I did search for an answer to this question before posting, I may not have known the right terms to use. If this is a duplicate question, I would be thrilled to be pointed in the right direction. :)
~~~UPDATED ANSWER~~~
Thanks to @Mandias for getting me on the right track. I was able to use week numbers to achieve my desired result.
from datetime import datetime, timedelta, date today = date.today() #get today's date todays_week = today.isocalendar()[1] #get the current week number based on today's date survey_week = todays_week + 6 #add 6 weeks to the current week number todays_year = int(today.strftime("%Y")) #get today's calendar year and turn it from a str to an int survey_week_tuesday = date.fromisocalendar(todays_year, survey_week, 2) #(year, week, day of week) 2 is for Tuesday print("Current Week Number:") print(todays_week) print("Current Week Number + 6 Weeks:") print(todays_week + 6) print("Today's Year:") print(todays_year) print("The Tuesday on the 6th week from the current week (i.e. survey tuesday):") print(survey_week_tuesday.strftime('%m-%d-%Y')) #using strftime to format the survey date into MM-DD-YYYY format because that's what we use here even though DD-MM-YYYY makes more sense
-
insert bulk documents into mongo db
I need to insert multiple docs into mongo db at once. cannot directly import a csv file or use insertMany since there are nested objects inside each document. for outer object, one key's value will change every time while the rest of the key's value remain the same and need to generate random values for two of the other keys. for inner object, values change every time. this seems complicated to me and if anyone could help me breakdown the problem statement and help me automate it to avoid the tedious manual work, it'd be very helpful. I'm using Studio 3T and node.js to code.
{ "_id" : ObjectId("626f6f7b4199350845746a54"), "isApproved" : false, "msgStatus" : false, "name" : "IN", "createdBy" : "BAA0704", "customerId" : "HH00012", "villageId" : "1848", "ans" : { "responseID" : "5f440bc3-c76c-411a-b1e4-6a25a5f2aba3", "submittedTime" : "31-03-2022 16:45", "syncedTime" : "31-03-2022 16:45", "formRevisionSubmittedIn" : "2", "tags" : "NA", "timeSpent" : "0:16:12", "name" : "shruthi", "villagePopulation" : "10000", "age" : "28", "bankAccount" : "yes", "familyMembers" : "7", "maritalStatusYes" : "Yes", "maritalStatusNo" : "No", "kids" : "3", "socialMediaHandles" : "facebook" }, "createdAt" : ISODate("2022-05-02T13:22:19.630+0000"), "updatedAt" : ISODate("2022-05-02T13:22:19.630+0000"), "__v" : NumberInt(4325), "nId" : NumberInt(11)
-
CFG of w != w^R
Given
L={w in {a,b}* | w != w^R}
I want to find its CFG. Please do not tell me the answer for that.
What is the intuition of solving these kind of questions?
I tried doing it for about 1 hour, with no luck.
Thanks!
-
How does Playwright tracing file compare to HAR file?
Playwright lets you record HAR, but there's also
context.tracing.start
. The latter also lets you capture screenshots to the resulting ZIP, but HAR file seems to be better supported outside of Playwright. So what is the difference, are trace files basically HAR files with screenshots, or is there any info missing that would be found in a HAR? -
Running Playwright dotnet tests on Azure DevOps
I'm trying to execute Playwright dotnet tests with Nunit framework on Azure DevOps. I'm unable to execute testcases as and when I try to install playwright as a part of pipeline, there is an error thrown and build gets failed with the following message
Couldn't find project using Playwright. Ensure a project or a solution exists in D:\a\1\s, or provide another path using -p. Below is my azure pipeline steps, Can someone please help me where exactly the issue is and I have tried both Windows and latest Ubuntu agents
# ASP.NET Core (.NET Framework) # Build and test ASP.NET Core projects targeting the full .NET Framework. # Add steps that publish symbols, save build artifacts, and more: # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core trigger: - master pool: vmImage: 'windows-latest' variables: solution: '**/*.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' steps: - task: UseDotNet@2 displayName: 'Install .NET' inputs: packageType: 'sdk' version: '6.0.x' installationPath: $(Agent.ToolsDirectory)/dotnet includePreviewVersions: true - task: DotNetCoreCLI@2 inputs: command: 'build' projects: '**/*.csproj' - task: DotNetCoreCLI@2 inputs: command: 'custom' custom: 'new' arguments: 'tool-manifest' - task: DotNetCoreCLI@2 displayName: 'Installing Playwright Cli' inputs: command: 'custom' custom: 'tool' arguments: 'install Microsoft.Playwright.CLI' - task: DotNetCoreCLI@2 displayName: 'Building tests project' inputs: command: 'build' projects: '**/*Tests*.csproj' - task: DotNetCoreCLI@2 displayName: Run Playwright Install inputs: command: custom custom: 'tool ' arguments: run playwright install - task: DotNetCoreCLI@2 displayName: 'Run tests' inputs: command: 'test' projects: '**/*Tests*.csproj' testRunTitle: 'new pipeline'
-
Testing keyboard accessibility: how to check what is selected with Playwright?
I have a React PWA that I am testing with Playwright.
I want to ensure everything in my PWA can be done using only the keyboard, so I want to write some tests in Playwright to verify this.
I use
keyboard.press
to input keys:await this.page.keyboard.press('Tab');
Now, I want to verify which element is selected when I press the tab key.
So, for example, say I select an email field by pressing the Tab key three times like this:
await this.page.keyboard.press('Tab'); await this.page.keyboard.press('Tab'); await this.page.keyboard.press('Tab');
Now, I expect the result to be that I am now ready to type something into the email field. How can I verify that I have selected a given element? In other words, what can I use in Playwright to say "tell me the id of the element on the page that has been selected via the keyboard?"
I've been trying to Google this but I don't know the right term.
-
How to execute playwright script using artillery
I am trying to execute playwright tests via artillery.io and I am facing issues
-
How to avoid "Duplicate test titles are not allowed" error in playwright-test?
Context: In long E2E test flows there are certain steps that are duplicated like moving in-between "Product" vs "shipping" vs "Payment method" tabs in an online order workflow.
Problem: In Playwright-Test, duplicate test titles are not allowed as "error" (not as a warning) which is painful for someone who is migrating test scripts from other testing frameworks like "Jasmine" (as in my scenario) where duplicate test titles were allowed.
Desired Solution : Is there a solution, where this error can be avoided on the configuration level (preferably as a warning) without changing 100s of scripts manually? Thanks!