所以我有一个名为folder的变量,其中包含我随机生成的字符串.我想使用xpath按名称查找此文件夹,我不知道如何将其付诸实践
driver.find_element_by_xpath('//div[text()="variable"]')
其中变量包含随机文本.使用sql就像这样(select * from table where value =(?)),[variable] …或类似的东西
解决方法
试试这个:
driver.find_element_by_xpath('//div[text()="%s"]' % variable)