Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
390 views
in Technique[技术] by (71.8m points)

java - Selenium @FindBy linkText or @FindBy partialLinkText not working

I'm working for automation, I'm trying to click on an element ,this element has no id, classname so I'm using the xpath. To improve my code I would like to find this element by href, so I'm using:

@FindBy(linkText="Transfer")
WebElement transferBtn;

I also tried with:

@FindBy(partialLinkText="Transfer")
WebElement transferBtn;

But my code doesn't find the webElement, it's working for other href but not all. I think the problem is developer tools, i'll show you the element:

<a href="#">My transfer</a>

Do you have any idea of the problem, why it's not working? Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Change Transfer to My transfer

@FindBy(linkText="My transfer")
WebElement transferBtn;

OR Change Transfer to transfer

@FindBy(partialLinkText="transfer")
WebElement transferBtn;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...