Using OR with Selenium.Click - is this possible?
There is an image and a link on this webpage. Clicking on either of them does the same job. I was wondering if there is an option of including OR in Selenium.Click. Something like:
Selenium.Click("image") OR Sele开发者_如何学JAVAnium.Click("link");
Selenium doesn't offer OR condition. If the requirement is to click on either of the locators depending on which one is available, then you can easily create a custom method
This is written in JAVA, you can change it to your programming language
public void ClickOnAvailableLocator(String locator1, String locator2)
{
if(selenium.isVisible(locator1)
selenium.Click(locator1);
else
selenium.Click(locator2);
}
No, if you need to test both routes I would suggest two tests.
精彩评论