0

I'm new in IT and automation QA, I have a trouble in using Selenium library and SeleniumLibrary in RobotFramework. As I know, the SeleniumLibrary will support using method as Keyword in Robot Framework (RF). Suppose in *.py file I can use Selenium to call open browser:

driver = webdriver.Chrome() driver.get("https://google.com") ...

and in *.robot I open a browser with SeleniumLibrary like:

open browser https://google.com

While researching for many solutions, I found many tutorials in Selenium and it was easy to understand and apply, but in my project, they's been extending the SeleniumLibrary by:

driver = SeleniumLibrary driver.open_browser("https://google.com") 

= driver.get("https://google.com") in *.py (from selenium import webdriver)

I feel hard to read the source code of SeleniumLibrary e.g If I need to use find_element(By.ID/CSS/etc.., "abc") in *.py and in SeleniumLibrary I only searched that

def find_element( self, locator: str, tag: Optional[str] = None, required: bool = True, parent: WebElement = None, ) 

I dont how to write code like before with selenium.webdriver.. Does anyone help me to clear them? How can I use driver.find_element (of SeleniumLibrary) in *.py file that equals driver.find_element_by_CSS_selector (of Selenium.webdriver)

    1 Answer 1

    1

    There're various strategies how to locate elements on a page, read about them in the documentation here.

    The point is that you want to do something with the element you locate, in Python, you'd typically do it in two steps, first find the element and then click on it (for example). In Robot Framework, you do it in one step like so:

    Click Element id:foo 

    That's all. Two steps are taken care of here:

    • finding the element in the DOM
    • clicking on the element

    Robot Framework is a bit more high-level than Python, so many tasks in it will require fewer lines of code. I think this is what you're asking about and are not really used to yet. I recommend using RF on a small project to learn it. You always have documentation ready on the Internet.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.