【问题标题】:How to check a value of a variable is an integer in Selenium WD using Python? [duplicate]如何使用 Python 在 Selenium WD 中检查变量的值是否为整数? [复制]
【发布时间】:2015-12-03 19:03:29
【问题描述】:
for product_name in self.mydriverOne.product_container.product_name:
    rt=product_name.text[:-1]
    print rt

我需要验证变量 rt 是 integer value。如何使用 Python 在selenium web driver 中做到这一点?

【问题讨论】:

    标签: python selenium selenium-webdriver webdriver


    【解决方案1】:

    您必须为此使用一些与 python 相关的编码。因为你已经在 'rt' 中有值,这可能是一个字符串。 现在你只需要检查它是否包含数值。我的意思是字符串是否像'1234'。 参考这个:How do I check if a string is a number (float) in Python?

    还有,

    Checking whether a variable is an integer or not

    【讨论】:

    • 有什么办法可以在 selenium 中使用断言来解决这个问题?
    • 我猜你正在寻找的是变量“rt”具有像“12345”等数值,对吧?我不确定python,但在java中这又可以做到:stackoverflow.com/questions/5439529/…
    猜你喜欢
    • 2019-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    • 2015-02-25
    • 1970-01-01
    • 2011-03-30
    • 2018-05-19
    相关资源
    最近更新 更多