New answers tagged

3

You can create have multiple implementations of your client object. import abc class MyServiceClient(abc.ABC): @abc.abstractmethod def get_item(self, id): pass class MyServiceClientStub(MyServiceClient): def get_item(self, id): return Item(1) class RealMyServiceClient(MyServiceClient): def get_item(self, id): # ...


0

After navigating to the new page if you want to do something on that new page newURl = driver.window_handles[0] driver.switch_to.window(newURl) After doing this you can do something in the new url without getting "no such element exceptions"


0

So the Selenium .Click() will wait for a page load if it notices one (and even then it might not wait long enough due to things like lazy-loading). The JSE doesn't wait for any response (unless the script cannot be ran due to bad syntax or something). That said, whenever I need to use the JSE .click() I am sure to have my next step be a Wait step, like wait ...


0

You want to consider using fixtures @pytest.fixture def f1(): pass # your steps should be here # you can also use fixtures to do steps after test: @pytest.fixture def f2(): pass # your "before test" steps should be here yield pass # your "after test" steps should be here More information: https://docs.pytest.org/en/latest/fixture.html


0

Use this locator instead: class='_2S1VP copyable-text selectable-text' if you open chrome dev tools and goto console tab: You can jquery expressions there which shows that the locator your using is not editable. so, if you check the element with class gQzdc . It is not editable. But, class='_2S1VP copyable-text selectable-text' is editable (giving true)


1

The above answer could help in making sure the elements are loaded properly. But the actual issue in your code is that you are not breaking the for loop after city.click() So, You click dropdown You click city Dropdown closes For loop still continues and tries to iterate through stale objects SO the fix: if city.text == "Chania, Greece": city.click() ...


0

The above postes is right. Code like this is bound to fail because the page may be half-loaded (not all DOM elements will be loaded and ready). You should ensure that the elements you are going to use are available. This is normally done with WebDriverWait. Another important module in Selenium is Expected conditions. Among the conditions is staleness_of ...


0

I would suggest to use something like this: List<WebElement> listOfElements = driver.findElements(By.xpath(yourXpath)); for(WebElement element : elements){ //actions with elements you intend to perform // or use index for any specific element in list }


3

I am not sure what the code you have there do as it is incomplete. So assuming that you want to do data driven testing, use RobotFramework-datadriver https://github.com/Snooz82/robotframework-datadriver#structure-of-data-file Installation: pip install --upgrade robotframework-datadriver pip install --upgrade robotframework-datadriver[XLS] Create the ...


0

you can create the input tag without triggering the click event by using javascript executor: body=driver.find_element_by_tag_name('body'); driver.execute_script("$(arguments[0]).prepend('<form enctype=\"multipart/form-data\" id=\"form-upload\" style=\"display: block;\"><input type=\"file\" name=\"file\" /></form>')", body); Note: I ...


0

You can make something like this: File: conftest.py option = None def pytest_addoption(parser): parser.addoption("--arg", action="store", default="example", help="Option for making some stuff") def pytest_configure(config): global option option = config.option and you can access your argument with option.arg in your conftest file.


0

In one of my projects we had to upload a .csv file. In order to achieve this we were storing the test files with in the solution and then uploading the files as needed. I used C# to implement this, but i am assuming you can try a similar approach in python. // Get the path of the folder where you stored the files public string GetPath() { var rootPath = ...


1

https://robot-framework.readthedocs.io/en/3.0/autodoc/robot.html robot class is the root of robotframework . So it seems like you don't have robotframework. Just install robotframework using : pip install robotframework --verbose And see if it's installing correct python site package. Update: The author confirmed that the issue was with RIDE , ...


0

In my case, before switch to the new window, a simply thread sleep make thing done. time.sleep(3) # switch to new window


Top 50 recent answers are included