在XPath -Selenium-初学者中使用卷曲括号
我正在使用硒,并想通过XPATH识别元素。我想使用的是这样的定位器:
ref_code = driver.find_elements_by_xpath("//tr[@data-eui-handler="{ event:'click',handler: 'eui.app.controller.search_results.selectRow' }"]/td[1]")
以语法错误结束,因为据我所见,字符串中的“事件”和“处理程序”是关键词。我该如何更改它,因此都被视为字符串?
我相信卷曲括号正在结束字符串格式吗?
抱歉,我是新手:)
谢谢 拍
I am using Selenium and want to identify an element via xpath. The locator I want to use looks like this:
ref_code = driver.find_elements_by_xpath("//tr[@data-eui-handler="{ event:'click',handler: 'eui.app.controller.search_results.selectRow' }"]/td[1]")
This ends in a syntax error because as far as I see "event" and "handler" in the string are key words. How can I change it, so it is all seen as a string?
I believe the curly brackets are ending the string format right?
Sorry, I am new to this :)
Thanks
Pat
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题不是括号,而是
“
使用
您需要在
之前将
之前,如果它们是字符串的一部分,\
放在The issue is not the brackets but the
"
Use
You need to put an
\
before"
if they are part of the string