Finding Elements

Hello,
i want to select a city and search any movie on https://www.palacecinemas.com.au/
(see right side of header centred logo ). Help me to search.

Hi @sushil173 you will want to step through each user action manually, and use findElement and/or waitForAndFindElement (I use the latter after a page transition) to find elements you would like to interact with:

.then(function() {
  //find search box
  return $browser.waitForAndFindElement($driver.By.id('search-box'))
}).then(function(searchInput) {
  //enter "star wars" into search box
  return searchInput.sendKeys('star wars');
})

Here is a very basic example I wrote searching for “star wars” on that page. I have not thoroughly tested this script so I recommend doing so before use in a Synthetics monitor:

$browser.get('https://www.palacecinemas.com.au/').then(function() {
  //click cities
  return $browser.findElement($driver.By.css('span.jcf-select-location')).click();
}).then(function() {
  //select "melbourne"
  return $browser.findElement($driver.By.xpath('//span[@data-index="4"]')).click();
}).then(function() {
  //find search box
  return $browser.waitForAndFindElement($driver.By.id('search-box'))
}).then(function(searchInput) {
  //enter "star wars" into search box
  return searchInput.sendKeys('star wars');
}).then(function() {
  //click search icon
  return $browser.findElement($driver.By.css('.icon-searchnew')).click();
});

thanks @btribbia for your reply.
I wrote script link this

$browser.get(“https://www.palacecinemas.com.au/”)
.then(function(){
//finding search box and search for Stars Wars
return $browser.findElement($driver.By.id(“search-box”)).sendKeys(“Stars Wars “);
}).then(function(){
//click search button
$browser.findElement($driver.By.className(“icon icon-searchnew”)).click();
}).then(function(){
//wait for result
$browser.waitForElement($driver.By.className(“result”),5000);
}).then(function(){
//click search item
return $browser.findElement($driver.By.xpath(”//[@id=‘main’]/div[3]/div/ul/li[1]/div/a")).click();
}).then(function(){
//click cities
$browser.findElement($driver.By.className(“jcf-select-opener”)).click();
//choose “Brisbane”
return $browser.findElement($driver.By.xpath("/html/body/div[8]/div/span/span/ul/li[3]/span")).click();
}).then(function(){
//wait for movie name.
$browser.waitForElement($driver.By.className(“go-next active”),10000);
}).then(function(){
//wait for cinema hall and click on it.
return $browser.waitForElement($driver.By.xpath("//
[@id=‘bymovie’]/div/div[2]/div/ul/li[2]”),15000).click();
}).then(function(){
//click on session time.
return $browser.waitForElement($driver.By.xpath("//*[@id=‘bymovie’]/div/div[3]/div/ul/li[4]/span[1]/a"),5000).click();
});

in most case, I used XPath too much, but really I don’t want to do like that.

You’re welcome @sushil173 ! I agree. Where possible, try to use CSS selectors or some a unique attribute such as id for locating elements. Lengthy/verbose xpaths can be rigid, causing unexpected failures for sites that frequently modify the DOM.