Answer the question
In order to leave comments, you need to log in
How to use AsyncTask along with Selenium?
With Selenium automation, I need to find an object on a page.
I'm looking for id. Throws an exception
Caused by: org.openqa.selenium.NoSuchElementException: Could not find element with id: search-text
E/NetworkUtilities: [MTK_net]ss.ss_family:2
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MyAsyncTask myAsyncTask = new MyAsyncTask();
myAsyncTask.execute(this);
}
class MyAsyncTask extends AsyncTask<Activity, Integer, Integer> {
@Override
protected Integer doInBackground(Activity... strings) {
WebDriver driver = new AndroidWebDriver(strings[0]);
driver.get("https://rutracker.appspot.com/forum/index.php");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
WebElement element = driver.findElement(By.id("search-text"));
element.sendKeys("гладиолус");
element.submit();
return null;
}
}
}
Answer the question
In order to leave comments, you need to log in
But this does not change the fact that you started to translate the topic. The task of the community is to try to help me, and not to reproach and ask questions that are not related to the topic.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question