How to set the driver - qaf

I want to set my local driver as the selenium driver. The question is qaf will start a new driver each time.
public static QAFExtendedWebDriver driver;
public static QAFExtendedWebDriver localDriver(){
System.setProperty("webdriver.chrome.driver","src/main/resources/webdriver/chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("debuggerAddress","localhost:9222");
ChromeDriver driver1 = new ChromeDriver(options);
QAFExtendedWebDriver webDriver = new QAFExtendedWebDriver(driver1);
driver = webDriver;
return driver;
}
and if I want to click a QAF webelement, it won't use my local driver
new QAFExtendedWebElement("Company").click();
Can someone help me with this?

The question is unclear, do you want to set behavior to create new driver for each test or to reuse driver instance? you should use selenium.singletone=method if you want to create new driver instance for each testcase. it will tear down driver instance after test get completed.
The code you have provided to create driver instance is not required when using qaf. To set which driver to use, you need to set driver.name property.
In order to use local driver, if remote word not used in driver name, it will use local driver. For instance chromeDriver refers to running chromdriver in local system. with qaf version 3+ you don't need to download driver executable or don't need to set webdriver.chrome.driver. It uses driver manager to download and set driver executable depending on local browser version.
if you want to set specific capability you can set using properties or using driver listener.
all you need to do is, in properties file set properties:
driver.name=chromeDriver
#set additional capabilities if required
#chrome.additional.capabilities={}
In code:
new QAFExtendedWebElement("element.locator").click();
//other way using common steps
//import static com.qmetry.qaf.automation.step.CommonStep.click;
click("element.locator")
//Another way of using element factory
//import static com.qmetry.qaf.automation.ui.webdriver.ElementFactory.$;
$("element.locator").click();
If you want driver instance anywhere in code:
QAFExtendedWebDriver driver = (QAFExtendedWebDriver)TestBaseProvider.instance().get().getUiDriver();
//another way
QAFExtendedWebDriver driver = new WebDriverTestBase().getDriver();
Refer:
https://qmetry.github.io/qaf/latest/properties_list.html
https://qmetry.github.io/qaf/latest/how_to_use_driver.html
https://qmetry.github.io/qaf/latest/locating_elements.html

Related

Configuring connection pool size with guice, mybatis, and c3p0 or bonecp

I'm using Guice/Mybatis to manage and execute my queries to a MySQL database. My class that sets up the connection and extends MyBatisModule contains these relevant bits:
Properties myBatisProperties = new Properties();
myBatisProperties.setProperty("c3p0.maxPoolSize", "5");
myBatisProperties.setProperty("c3p0.initialPoolSize", "5");
bindDataSourceProviderType(C3p0DataSourceProvider.class);
bindTransactionFactoryType(JdbcTransactionFactory.class);
addMapperClass(getMapperClass());
Names.bindProperties(binder(), myBatisProperties);
bind(getBindServiceClass()).to(getBindServiceToClass());
When I configure either using c3p0 or bonecp using its properties of bonecp.maxConnectionsPerPartition and bonecp.partitionCount, and the appropriate DataSourceProvider.class in place of C3p0DataSourceProvider, both c3p0 and bonecp ignore my max connections configuration and just open (and hold open) a new connection for every query until mysql runs out of available connections.
When I use the default mybatis pool provider PooledDataSourceProvider and its properties, mybatis.pooled.maximumActiveConnections and mybatis.pooled.maximumIdleConnections, it respects my configuration and pools connections correctly.
What am I doing wrong?
Further documentation for this is available at http://mybatis.github.io/guice/datasources.html
It looks like the problem was due to the my creating a new injector every time. Specifically this line:
Injector injector = Guice.createInjector(new MyDAOPoolModule());
return injector.getInstance(MyDAOService.class);
If instead I make the injector a singleton, it only creates the one pool.

Retrieve vm summary on Jconsole

I need to access the VM arguements from the VM summary tab on jconsole programmatically.. i.e using java.
Am using JMX to create connection to a remote server. using method
MBeanServerConnection connection = JMXConnector.getMBeanServerConnection();
When I used Jconcole to monitor the jmx connection, there is a lot of information on VM summary tab. I need the VM arguements particularly to use in my program.
Please guide !!
I got the answer to the question. In case someone needs it.. Use this code:
ObjectName objName = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
String[] vendor = (String[]) mbsc.getAttribute(objName, "InputArguments");
This will return array of strings that contains vm arguments. you can pass different paramenters to query the RuntimeMxBean.

Thingsquare Router-Node

I´m newbie with Thingsquare
I'm traying to create a IP64 Gateway with MB851 Board (STM32W108CC microprocessor)
I send and receive data (IPv6 Radio) using 2 MB851 Boards with Thingsquare udp-multicast example.
I modified mist-mb851 platform to include an enc28j60-arch.c file to implement the platform code of SPI functions that are called by the enc28j60 driver
I modified ip64-conf.h to include enc28j60 driver and fallback interface
include "ip64-eth-interface.h"
include "enc28j60-ip64-driver.h"
define IP64_CONF_UIP_FALLBACK_INTERFACE ip64_eth_interface
define IP64_CONF_INPUT ip64_eth_interface_input
define IP64_CONF_DHCP 1
define IP64_CONF_ETH_DRIVER enc28j60_ip64_driver
I modified Contiki/platform/mb851 to include STM32 PeripheralLibs to create the SPI driver
The enj28j60 driver is tested
I compile the Thingsquare Router-Node example but when initialize the DHCP process
ip64_init();--->ip64_ipv4_dhcp_init();--->ip64_dhcpc_request();--->handle_dhcp();--->send_discover();
Nothing happens
Debugging the code when tcpip_ipv6_output(); function is call to send the packet the function ip64_6to4(...); fails and i don´t know why
Best Regards

JavaMail and the Blackberry JRE

I am trying to make use of the JavaMail jar on my blackberry app so I can access my GMail emails. I usually make use of this sort of function:
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
String html_email = "";
try {
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", email, password);
However, eclipse is complaining about the Properties object as I am not making use of the standard JRE but rather the blackberry JRE.
Is there anyway, I can work around this with minimal changes to my function as far as the Properties is concerned?
In addition, I am having trouble with the use of System:
The method getProperties() is
undefined for the type System.
Is this even likely to work?!
Thanks all
Hmm, looks like JavaMail is not built for use on JavaME.

Windows XPE service installation - how to set security at CreateService time?

I'm using CreateService to install a windows service on Windows XPE. I'd like to set things up so that only the Administrator can start/stop/pause/resume the service.
Right now I'm using the following to install the service:
schService = CreateService(schSCManager,
ServiceName,
ServiceDisplayName, // service name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS, // service type
SERVICE_AUTO_START, // start type
SERVICE_ERROR_NORMAL, // error control type
binaryPathName, // service's binary (this program)
NULL, // no load ordering group
NULL, // no tag identifier
NULL, // no dependencies
NULL, // LocalSystem account
NULL); // no password
And the service ends up with security such that members of the PowerUsers group can start and stop the service. I've figured out that I can use sc sdshow to examine the security descriptor, and I've worked out an SDDL line that would do the right thing for us.
I've also learned that our Win XPE install doesn't have the sc.exe binary on it, so we can't really use that to setup this particular system.
So, what I need to know is: What are the APIs I need to use, to set the security descriptor on this service around the time I do the CreateService call. I'm completely unfamiliar with the Windows security APIs, so I just don't know where to start.
UPDATE: The answer is SetServiceObjectSecurity (below). Next question: What's the best way to setup the SecurityDescriptor? Is it best to get the default descriptor, then modify it? Or should I just create a completely new descriptor?
I'm not really familiar with Windows XP Embedded, but normally you would achieve what you are after using the SetServiceObjectSecurity function. Use the handle you get from CreateService and build a security descriptor that matches what you want.

Resources