4

Autoit has a order value ,which I want to pass it to database as argument to get table contents of that order id.

I tried passing from command line ,but I don't want the arguments to get passed from command line. I am using Selenium web driver with Java.

0

You could store them in an .INI file and read this during your tests in your @BeforeClass using:

Preferences args = new IniFile(new File(fname));

Since my tests are coming from HP ALM and the testng-suite.xml is generated automatically, I simply added my arguments as parameters into the XML. You could also use AutoIt to add the lines into your testng-suite.xml

<suite verbose="-1" name="TestAutomationTest.MBC-POS-Suite" configfailurepolicy="skip" preserve-order="true">
    <parameter name="selenium.url" value="https://dfs.com" />

You can access them then in your test method, each parameter is one argument in your test method:

@Test
@Parameters({"selenium.url", "timeOut.msec"})
public void testMethod(String url, int timeout)
0

Below is the code snippet to pass arguments to autoit script, which then can be used in Selenium for uploading a file where we can pass the file path dynamically.

ControlFocus("File Upload", "", "Edit1")
ControlSetText("File Upload", "", "Edit1", $CmdLine[1])
ControlClick("File Upload", "" , "Button1")

Here, CmdLine[1] is the argument that we are passing dynamically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.