AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-851097

Chris Hansen's questions

Martin Hope
Chris Hansen
Asked: 2025-04-26 01:56:07 +0800 CST

如何在 playwright 中打字变慢?

  • 5

我一直使用“填充”功能在 Playwright 的文本框内输入内容,但这会导致自动化脚本运行速度过快——比人手还快。我希望输入速度能和人手一样快。有没有其他方法可以替代“填充”功能来填充文本框?

playwright
  • 1 个回答
  • 44 Views
Martin Hope
Chris Hansen
Asked: 2025-02-15 01:49:37 +0800 CST

元素未位于页面中央

  • 1

我有以下代码

    let scrollView = UIScrollView()
    scrollView.translatesAutoresizingMaskIntoConstraints = false
    scrollView.showsHorizontalScrollIndicator = false
    scrollView.showsVerticalScrollIndicator = false
    view.addSubview(scrollView)
    
    NSLayoutConstraint.activate([
        scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
        scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
        scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
        scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
    ])
    
    let contentView = UIView()
    contentView.translatesAutoresizingMaskIntoConstraints = false
    scrollView.addSubview(contentView)
    
    contentView.backgroundColor = UIColor(red: 0.97, green: 0.98, blue: 0.99, alpha: 1.00)
    
    NSLayoutConstraint.activate([
        contentView.topAnchor.constraint(equalTo: scrollView.topAnchor),
        contentView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
        contentView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),
        contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor)
    ])
    
    // Large Label
    let largeLabel: UILabel = {
        let label = UILabel()
        label.text = "Congrats!"
        label.font = UIFont(name: "Inter-Bold", size: 24)
        label.textAlignment = .center
        label.numberOfLines = 0
        label.translatesAutoresizingMaskIntoConstraints = false
        return label
    }()
    
    // Small Label
    let smallLabel: UILabel = {
        let label = UILabel()
        label.text = "Your finished the \(category.name) lesson."
        label.font = UIFont(name: "Inter-Regular", size: 16)
        label.textColor = .black
        label.textAlignment = .center
        label.numberOfLines = 0
        label.lineBreakMode = .byWordWrapping
        label.translatesAutoresizingMaskIntoConstraints = false
        return label
    }()
    
    
    // Image View
    let animatedImageView: UIImageView = {
        let imageView = UIImageView(image: UIImage(named: "fire"))
        imageView.tintColor = .systemYellow
        imageView.contentMode = .scaleAspectFit
        imageView.translatesAutoresizingMaskIntoConstraints = false
        return imageView
    }()
    
    
    contentView.addSubview(largeLabel)
    contentView.addSubview(smallLabel)
    contentView.addSubview(animatedImageView)
    
    
    let totalScore = score + WUser.sharedInstance.getUserScore()
    var nextLevel = ""
    var currentLevel = ""
    var toXP = 0
    
    let pointsView = UIView()
    pointsView.layer.cornerRadius = 20
    pointsView.backgroundColor = .white
    pointsView.layer.borderColor = UIColor.gray.cgColor
    pointsView.layer.borderWidth = 1
    pointsView.layer.masksToBounds = true
    pointsView.translatesAutoresizingMaskIntoConstraints = false
    contentView.addSubview(pointsView)
    
    let pointsLabel: UILabel = {
        let label = UILabel()
        label.text = "Points Earned"
        label.font = UIFont(name: "Inter-Bold", size: 16)
        label.translatesAutoresizingMaskIntoConstraints = false
        return label
    }()
    
    let percentageLabel: UILabel = {
        let label = UILabel()
        label.text = "+\(score + 5)"
        label.font = UIFont(name: "Inter-Bold", size: 16)
        label.translatesAutoresizingMaskIntoConstraints = false
        return label
    }()
    
    let iconImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.contentMode = .scaleAspectFit
        imageView.image = UIImage(systemName: "star.fill")
        imageView.tintColor = UIColor(red: 0.63, green: 0.14, blue: 0.92, alpha: 1.00)
        imageView.translatesAutoresizingMaskIntoConstraints = false
        return imageView
    }()
       
    let progressView = UIProgressView(progressViewStyle: .default)
    progressView.progress = 0
    progressView.layer.cornerRadius = 10
    progressView.layer.masksToBounds = true
    progressView.trackTintColor = UIColor(red: 0.91, green: 0.91, blue: 0.91, alpha: 1.00)
    progressView.progressTintColor = UIColor(red: 0.63, green: 0.14, blue: 0.92, alpha: 1.00)
    progressView.translatesAutoresizingMaskIntoConstraints = false

    
    if totalScore < 5 {
        currentLevel = "Level 1"
        nextLevel = "Starter"
        toXP = 5 - totalScore
    } else if totalScore < 50 {
        currentLevel = "Starter"
        nextLevel = "Trailblazer"
        toXP = 50 - totalScore
    } else if totalScore < 100 {
        currentLevel = "Trailblazer"
        nextLevel = "Champ"
        toXP = 100 - totalScore
    } else if totalScore < 200 {
        currentLevel = "Champ"
        nextLevel = "Genius"
        toXP = 200 - totalScore
    } else if totalScore < 500 {
        currentLevel = "Champ"
        nextLevel = "Genius"
        toXP = 500 - totalScore
    } else {
        currentLevel = "Genius"
        nextLevel = "Genius"
    }
    
    
    let xpLabel: UILabel = {
        let label = UILabel()
        label.text = "\(toXP) XP to \(nextLevel)"
        label.font = UIFont(name: "Inter-Regular", size: 14)
        label.translatesAutoresizingMaskIntoConstraints = false
        return label
    }()
    
    pointsView.addSubview(pointsLabel)
    pointsView.addSubview(percentageLabel)
    pointsView.addSubview(iconImageView)
    contentView.addSubview(progressView)
    contentView.addSubview(xpLabel)
    
    NSLayoutConstraint.activate([
        largeLabel.topAnchor.constraint(equalTo: contentView.safeAreaLayoutGuide.topAnchor, constant: 20),
        largeLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
        largeLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
        
        // Small Label Constraints
        smallLabel.topAnchor.constraint(equalTo: largeLabel.bottomAnchor, constant: 20),
        smallLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
        smallLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
        
        animatedImageView.topAnchor.constraint(equalTo: smallLabel.bottomAnchor, constant: 40),
        animatedImageView.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
        animatedImageView.widthAnchor.constraint(equalToConstant: 150),
        animatedImageView.heightAnchor.constraint(equalToConstant: 150),
            
        pointsView.topAnchor.constraint(equalTo: animatedImageView.bottomAnchor, constant: 50),
        pointsView.widthAnchor.constraint(equalToConstant: 300),
        pointsView.heightAnchor.constraint(equalToConstant: 50),
        pointsView.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
        
        pointsLabel.leadingAnchor.constraint(equalTo: pointsView.leadingAnchor, constant: 16),
        pointsLabel.centerYAnchor.constraint(equalTo: pointsView.centerYAnchor),
        
        percentageLabel.trailingAnchor.constraint(equalTo: iconImageView.leadingAnchor, constant: -8),
        percentageLabel.centerYAnchor.constraint(equalTo: pointsView.centerYAnchor),
        
        iconImageView.trailingAnchor.constraint(equalTo: pointsView.trailingAnchor, constant: -16),
        iconImageView.centerYAnchor.constraint(equalTo: pointsView.centerYAnchor),
        iconImageView.widthAnchor.constraint(equalToConstant: 24),
        iconImageView.heightAnchor.constraint(equalToConstant: 24),
        
        
        progressView.leadingAnchor.constraint(equalTo: pointsView.leadingAnchor, constant: 16),
        progressView.trailingAnchor.constraint(equalTo: pointsView.trailingAnchor, constant: -16),
        progressView.topAnchor.constraint(equalTo: pointsView.bottomAnchor, constant: 30),
        progressView.heightAnchor.constraint(equalToConstant: 20),
        
        xpLabel.leadingAnchor.constraint(equalTo: progressView.leadingAnchor),
        xpLabel.topAnchor.constraint(equalTo: progressView.bottomAnchor, constant: 10)
    ])
    
    
    let instructionLabel = UILabel()
    instructionLabel.text = "How would you rate the lesson?"
    instructionLabel.textAlignment = .center
    instructionLabel.font = UIFont(name: "Inter-Bold", size: 18)
    instructionLabel.translatesAutoresizingMaskIntoConstraints = false
    
    let starsStackView = UIStackView()
    starsStackView.axis = .horizontal
    starsStackView.alignment = .center
    starsStackView.distribution = .equalSpacing
    starsStackView.spacing = 10
    starsStackView.translatesAutoresizingMaskIntoConstraints = false
    
    for i in 1...5 {
        let button = UIButton(type: .system)
        button.tag = i
        button.setTitle("★", for: .normal)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 30)
        button.setTitleColor(.lightGray, for: .normal)
        button.addTarget(self, action: #selector(starTapped(_:)), for: .touchUpInside)
        starsStackView.addArrangedSubview(button)
    }
    
    let submitButton = UIButton(type: .system)
    submitButton.setTitle("Submit Rating", for: .normal)
    submitButton.backgroundColor = UIColor(red: 0.35, green: 0.25, blue: 0.55, alpha: 1.00)
    submitButton.setTitleColor(.white, for: .normal)
    submitButton.layer.cornerRadius = 20
    submitButton.titleLabel?.font = UIFont(name: "Inter-Bold", size: 16)
    submitButton.addTarget(self, action: #selector(submitRating), for: .touchUpInside)
    submitButton.translatesAutoresizingMaskIntoConstraints = false
    
    
    let closeButton = UIButton(type: .system)
    closeButton.setTitle("Close", for: .normal)
    closeButton.setTitleColor(.gray, for: .normal)
    closeButton.titleLabel?.font = UIFont(name: "Inter-Bold", size: 16)
    closeButton.addTarget(self, action: #selector(goBack), for: .touchUpInside)
    closeButton.translatesAutoresizingMaskIntoConstraints = false
    
    contentView.addSubview(instructionLabel)
    contentView.addSubview(starsStackView)
    contentView.addSubview(submitButton)
    contentView.addSubview(closeButton)
    
    NSLayoutConstraint.activate([
        instructionLabel.topAnchor.constraint(equalTo: xpLabel.bottomAnchor, constant: 30),
        instructionLabel.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
        
        starsStackView.topAnchor.constraint(equalTo: instructionLabel.bottomAnchor, constant: 20),
        starsStackView.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
        
        submitButton.topAnchor.constraint(equalTo: starsStackView.bottomAnchor, constant: 20),
        submitButton.widthAnchor.constraint(equalToConstant: 250),
        submitButton.heightAnchor.constraint(equalToConstant: 50),
        submitButton.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
        
        
        closeButton.topAnchor.constraint(equalTo: submitButton.bottomAnchor, constant: 20),
        closeButton.widthAnchor.constraint(equalToConstant: 250),
        closeButton.heightAnchor.constraint(equalToConstant: 50),
        closeButton.centerXAnchor.constraint(equalTo: contentView.centerXAnchor),
        closeButton.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -20.0)
    ])
    
    
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
        UIView.animate(withDuration: 1.5) {
            progressView.setProgress(Float(Float(totalScore)/500), animated: true)
        }
    }
    
    UIView.animate(withDuration: 1.0,
                   delay: 0,
                   options: [.autoreverse, .repeat],
                   animations: {
        animatedImageView.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)
    }, completion: { _ in
        animatedImageView.transform = .identity
    })

不幸的是,这些元素没有位于页面中央。它们移到了屏幕的左侧。

请参阅附件

有人可以帮忙吗?

在此处输入图片描述

  • 2 个回答
  • 40 Views
Martin Hope
Chris Hansen
Asked: 2024-12-04 06:29:20 +0800 CST

无法在 Playwright 中找到项目

  • 5

我的代码中有以下元素

<sp-textfield id="library-name-textfield" data-testid="library-name-textfield" quiet="" placeholder="Name" dir="ltr" type="text" focusable="">
     #shadow-root
       <input class="input" type="text" aria-describedby="sp-help-text" aria-label="Yourname" placeholder="Your name">
</sp-textfield>

我尝试执行以下操作:

await this.inputBrandLibNameTxtBox().waitFor({ state: "visible", timeout: 20000 });
await this.inputBrandLibNameTxtBox().fill(brandName);

在哪里:

    inputBrandLibNameTxtBox = () => this.page.getByTestId("library-name-textfield").locator("input");

我收到错误:

TimeoutError: locator.fill: Timeout 20000ms exceeded.
Call log:
  - waiting for getByTestId('library-name-textfield').locator('input')
  -   locator resolved to <input type="text" class="input" aria-label="Your brand name" placeholder="Your brand name" aria-describedby="sp-help-text-2f4953d1"/>
  -   fill("new-brand--1733244070919")
  - attempting fill action
  -   waiting for element to be visible, enabled and editable

我该如何修复此问题?

playwright
  • 1 个回答
  • 27 Views
Martin Hope
Chris Hansen
Asked: 2024-12-02 20:12:01 +0800 CST

类型“Any”不能符合“Equatable”

  • 5

我有以下代码

 if let id = items[indexPath.row]["id"] {
     if let idx = savedGoals.index(of: id) {
        savedGoals.remove(at: idx)
     }
 }

我得到了错误Type 'Any' cannot conform to 'Equatable'

在线的if let idx = savedGoals.index(of: id) {

savedGoals 声明为

var savedGoals = []

有人知道我为什么会收到这个错误吗?

swift
  • 1 个回答
  • 48 Views
Martin Hope
Chris Hansen
Asked: 2024-11-01 01:58:35 +0800 CST

检查是否可以滚动到页面末尾

  • 3

我在一个页面上有多个 div 框。我想检查是否可以滚动到页面末尾。昨天网站上有一个错误,用户无法滚动到页面末尾。如何使用 playwright 检查这个问题?

javascript
  • 1 个回答
  • 48 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve