From within my app I want to hit a website and than perform user action. Currently am using webview but I think webdriver will be easy to use and correct approach.
Current code:
WebView browser = (WebView) view.findViewById(R.id.webview);
browser.getSettings().setJavaScriptEnabled(true);
browser.getSettings().setDomStorageEnabled(true);
browser.getSettings().setUserAgentString(`"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.81 Safari/537.36");`
browser.setWebViewClient(new MyBrowser());
browser.loadUrl("https://myurl.com");
Issues with current code: Its hard to send key stores or use Xpath.
What am looking for? Hit the website using driver and than click buttons etc. Pseudo code as follows:
chat=driver.find_element_by_xpath("/html/somepath")
chat.click()
time.sleep(2)
search=driver.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/div[1]/span/div/span/div/div[1]/div/label/input")
search.click()
I understand that this is possible using selenium/appium. But what am confused is does selenium/appium also needs a server that runs on a separate machine? I want to run all of the code in my app without external server or any more apps.
Can I just add lib which gives me access to apis like I showed above?